开发者

Disabling warnings about Boost headers in XCode 4.1

开发者 https://www.devze.com 2023-04-02 04:01 出处:网络
I am writing a C+开发者_C百科+ program that uses Boost, using XCode 4.1 as IDE and compiler front-end. I get quite a lot of warnings in various Boost headers, and I would like to disable all warnings

I am writing a C+开发者_C百科+ program that uses Boost, using XCode 4.1 as IDE and compiler front-end. I get quite a lot of warnings in various Boost headers, and I would like to disable all warnings for those headers (but still enable them for my own project). Is there an easy way to do so?

Disabling warnings about Boost headers in XCode 4.1


I have found a decent workaround, based on what @Georg Fritzsche suggested: I have added the various incriminated boost headers to the .pch file (the pre-compiled header), and wrapped them around a #pragma push - #pragma pop block, like this:

// We do not want to have warnings about Boost headers!
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wshadow"

#include <boost/date_time/posix_time/posix_time_types.hpp>
...
#pragma GCC diagnostic pop

This works perfectly, and it's not as annoying as having to surround the boost headers with #pragma in each .cpp file, as I feared.


Another solution, that I found to work in Xcode 5.x (yet it is expected to work with Xcode 4). In the Build Settings of the Boost depending target, instead of setting the headers' path under Header Search Paths, I write it under Other C++ Flags, prefixed by -isystem

Disabling warnings about Boost headers in XCode 4.1

0

精彩评论

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

关注公众号