How to disable GCC warnings for a few lines of code

后端 未结 9 945
我寻月下人不归
我寻月下人不归 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条回答
  •  借酒劲吻你
    2020-11-22 09:12

    To net everything out, this is an example of temporarily disabling a warning:

    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wunused-result"
        write(foo, bar, baz);
    #pragma GCC diagnostic pop
    

    You can check the GCC documentation on diagnostic pragmas for more details.

提交回复
热议问题