Suppression: "#warning - language extension"

In the project I have included pedantic warnings. But now this gives me a warning about using #warning :

Lexical preprocessor problem
#warning - language extension

Firstly, I would like to know why this is happening and how to stop it (without removing #warning).

+4
source share
2 answers

The reason it is created is because #warning is an extension of the ISO standard, and that is what #warning is about.

It seems that only #pragma will disable it, because the -Wno-xxx flags will appear for language extensions.

 #pragma clang diagnostic push #pragma clang diagnostic ignored "-pedantic" #warning blah blah blah #pragma clang diagnostic pop 
+6
source

trojanfoe replied why the issue was released (+1).

A more flexible and user-friendly way to generate your warning message:

 #pragma message("YOUR WARNING HERE") 

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

+7
source

Source: https://habr.com/ru/post/1444363/


All Articles