Reputation: 7576
I'm developing an iOS app and am using the shared-pointer from the Boost library. My app is a little chunky, so I've been trying to lean it up. I think moving this line:
#include <boost/shared_ptr.hpp>
From individual files to the pre-compiled header file will save me some space since I heard every include of shared_ptr recompiles a different version and it's unclear whether the compiler is removing the duplicates.
When I move this line to the pch file I get a ton of compile-time errors, most of which are:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'boost'
I've changed the .pch file to be a sourcecode.cpp.h file in its info, but that hasn't helped.
Thoughts?
EDIT: Just verified that there are in fact duplicate copies of the compiled shared_ptr in my binary!
Upvotes: 1
Views: 1334
Reputation: 2447
Are you included Boost headers in a .m file or .mm files? Because in the first case the compiler will use Objective-C, in the second case Objective-C++.
Upvotes: 1
Reputation: 104698
You probably have C or ObjC sources in your project.
In that case:
#if defined(__cplusplus)
#include <boost/shared_ptr.hpp>
#endif
Xcode (by default) creates a prefix for every language/dialect in your project, and if it doesn't, it's still manually #include
d. Unfortunately, moving a header to a pch could only add duplicates. It could reduce your build times, however.
Upvotes: 1