How to disable GCC warnings for a few lines of code

后端 未结 9 913
我寻月下人不归
我寻月下人不归 2020-11-22 08:32

In Visual C++, it\'s possible to use #pragma warning (disable: ...). Also I found that in GCC you can override per file compiler flags. How can I do this for \"next line\",

9条回答
  •  萌比男神i
    2020-11-22 09:09

    For those who found this page looking for a way to do this in IAR, try this:

    #pragma diag_suppress=Pe177
    void foo1( void )
    {
       /* The following line of code would normally provoke diagnostic 
          message #177-D: variable "x" was declared but never referenced.
          Instead, we have suppressed this warning throughout the entire 
          scope of foo1(). 
       */
       int x;
    }
    #pragma diag_default=Pe177
    

    See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0472m/chr1359124244797.html for reference.

提交回复
热议问题