为什么“pragma GCC诊断推送”在GCC / C ++中弹出警告? [英] Why "pragma GCC diagnostic push" pop warning in GCC/C++?
问题描述
#pragma GCC diagnostic push
it pop:warning:expected [error | warning | ignored] code>
为什么?我在Linux中使用GCC。
我有一个问题,如果我不能使用pop / push,如果忽略 only cpp,不影响其他cpp?
#pragma GCC诊断推送$
c $ c>和 #pragma GCC诊断流行音乐
是新增的gcc 4.6 。您使用的是旧版本。
这些编译指示通常与其他#pragma GCC diagnostic
指令,以抑制,打开或转换为代码的一小部分的特定错误警告只要。如果它们被忽略,对警告级别的更改将应用于源文件的其余部分,而不是直到下一个 #pragma GCC诊断pop
。这可能不是一个问题,或者它可能是世界的尽头;您需要了解您的代码,以确定是否知道。
无论如何,你应该更新你的编译器。你不会用C89编译器编译C99;不要使用gcc 4.4编译包含gcc 4.6的编译指令的代码。
#pragma GCC diagnostic push
it pop: warning: expected [error|warning|ignored] after â#pragma GCC diagnosticâ
Why? I use GCC in Linux.
I have one question, if I can't use pop/push, if the ignore only influence the compiled cpp, not influence other cpp? if some other include the cap, if influence it?
#pragma GCC diagnostic push
and #pragma GCC diagnostic pop
were added in gcc 4.6. You're using an older version.
These pragmas are typically used in conjunction with other #pragma GCC diagnostic
directives to suppress, turn on, or turn into an error specific warnings for a small section of your code only. If they're ignored, the changes to warning levels will apply to the rest of the source file rather than just until the next #pragma GCC diagnostic pop
. This may not be a problem, or it may be the end of the world; you'll need to understand your code to know for sure.
Either way, you should probably update your compiler. You wouldn't compile C99 with a C89 compiler; don't compile code containing pragmas for gcc 4.6 with gcc 4.4.
这篇关于为什么“pragma GCC诊断推送”在GCC / C ++中弹出警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!