Is there a gcc / Xcode pragma to suppress warnings?

Is there any #pragmaway for gcc / Xcode to suppress certain warnings similar to Java annotation @SuppressWarning?

I compile with -Wall, as a rule, but there are some situations where I would just ignore a specific warning (for example, when writing some kind of quick / dirty code to help debug something).

I am not looking for "fix code" answers.

+3
source share
2 answers

Here is a viable solution . Use #pragma GCC system_headerGCC to process your code in a very special way, thus suppressing any non-fatal one #warning.

, , . .

+3

gcc4.6 , :

#pragma GCC diagnostic 
push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 
// Code that causes warning goes here
#pragma GCC diagnostic pop

push/pop , , .

, "#pragma GCC system_header" . (, gcc "" #pragma GCC system_header!)

gcc-: http://www.dbp-consulting.com/tutorials/SuppressingGCCWarnings.html

, -fdiagnostics-show-option, , .

, , , ! .

+2

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


All Articles