开发者

Apple LLVM compiler -- use pragmas to inhibit all warnings for a portion of a file?

开发者 https://www.devze.com 2023-03-28 12:06 出处:网络
I need inhibit war开发者_运维百科nings for part of one of my source files.This is what I have.It\'s not working.

I need inhibit war开发者_运维百科nings for part of one of my source files. This is what I have. It's not working.

 #pragma GCC diagnostic push
 #pragma GCC "-w"  // also tried "-Wall"

     // code that generates warnings here

 #pragma GCC diagnostic pop


You can disable individual warnings using the format:

#pragma GCC diagnostic ignored "-Wwarning-to-disable"

Except, that doesn't work for "-Wall", only for individual warnings. I would recommend only disabling the particular warning you're experiencing, and only if it's in source files over which you've no control. If it's in your code, you should seriously consider fixing the warnings in the proper way.

Edit: See Section 3.8, Options to Request or Suppress Warnings, in the GCC docs.

Edit 2: Ah, didn't realize that isn't a comprehensive list. There doesn't appear to be any documentation containing a comprehensive list, but you can always check the source. Poking around the clang source, it looks like include/clang/Basic/DiagnosticGroups.td lists a whole bunch of them.


If using XCode, you can go to the build log and expand the compiler output and it will tell you the warning name to use in the pragma

0

精彩评论

暂无评论...
验证码 换一张
取 消