Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"#pragma GCC diagnostic warning" with GCC [duplicate]

Tags:

c++

warnings

I use GCC 4.5.1 and get warnings like:

warning: expected [error|warning|ignored] after '#pragma GCC diagnostic'

The reason is "#pragma GCC diagnostic push", which doesn't exist for GCC before version 4.6.

I can't change the code (it is not my) and the GCC version too. How can I disable these warnings? Some GCC flags may be?

P.S.: I saw Why "pragma GCC diagnostic push" pop warning in GCC/C++?, but there isn't answer to my question.

like image 507
klm123 Avatar asked Feb 16 '23 13:02

klm123


1 Answers

GCC has these two flags to control warnings regarding pragmas:

-Wunknown-pragmas
Warn when a "#pragma" directive is encountered that is not understood by GCC. If this command-line option is used, warnings are even issued for unknown pragmas in system header files. This is not the case if the warnings are only enabled by the -Wall command-line option.

-Wno-pragmas
Do not warn about misuses of pragmas, such as incorrect parameters, invalid syntax, or conflicts between pragmas. See also -Wunknown-pragmas.

You can turn them off with -Wno-unknown-pragmas.

like image 152
nos Avatar answered Mar 03 '23 19:03

nos