在Visual C++中,可以使用#pragma warning (disable: ...)
.我还发现,在GCC中,可以使用override per file compiler flags.我怎样才能在"下一行"中做到这一点,或者在使用GCC的代码区域中使用push/pop语义?
在Visual C++中,可以使用#pragma warning (disable: ...)
.我还发现,在GCC中,可以使用override per file compiler flags.我怎样才能在"下一行"中做到这一点,或者在使用GCC的代码区域中使用push/pop语义?
看起来是can be done.我无法确定添加的GCC版本,但它是在2010年6月之前的某个时候.
下面是一个示例:
#pragma GCC diagnostic error "-Wuninitialized"
foo(a); /* error is given for this one */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
foo(b); /* no diagnostic for this one */
#pragma GCC diagnostic pop
foo(c); /* error is given for this one */
#pragma GCC diagnostic pop
foo(d); /* depends on command line options */