Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing: "#warning is language extension"

In an xcode4.5 project I have turned on pedantic warnings. But this now gives me a warning about using #warning:

Lexical preprocessor issue
#warning is language extension

Firstly, I'd like to know why this is happening and how to stop it (with out removing the #warning).

like image 492
Richard Stelling Avatar asked Nov 06 '12 13:11

Richard Stelling


People also ask

What do you mean by suppressing?

to do away with by or as by authority; abolish; stop (a practice, custom, etc.). to keep in or repress (a feeling, smile, groan, etc.).

What is the meaning of suppression in psychology?

n. 1. a conscious effort to put disturbing thoughts and experiences out of mind, or to control and inhibit the expression of unacceptable impulses and feelings. It is distinct from the unconscious defense mechanism of repression in psychoanalytic theory.


2 Answers

trojanfoe answered why the issue was emitted (+1).

A more portable and language-compliant way to emit your warning message is:

#pragma message("YOUR WARNING HERE")

Clang will emit one warning (specifically, the one you wrote in the message -- not the pedantic one), and it appears in Xcode's issues.

like image 191
justin Avatar answered Sep 30 '22 16:09

justin


The reason it's being generated is because #warning is an extension to the ISO standard and that is what -pedantic is about.

It looks like only a #pragma will turn it off as no -Wno-xxx flags appear available for language extensions.

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-pedantic"

#warning blah blah blah

#pragma clang diagnostic pop
like image 42
trojanfoe Avatar answered Sep 30 '22 15:09

trojanfoe