Trying to get rid of a c++ boost warning
Question
Whenever I include boost in my project I get a million of these warnings. Does anyone know how I can get rid of the warnings?
../depends\boost/config/abi_prefix.hpp(19) : warning C4103: 'depends\boost\config\abi_prefix.hpp' : alignment changed after including header, may be due to missing #pragma pack(pop)
I know I can do a #pragma to disable the warning, but I'd like to know the reason for these warnings.
Solution
The reason is that boost doesn't push/pop these pragmas in every file that needs data to be packed. They #include a separate file which does the push (abi_prefix.hpp), and then another (abo_suffix.hp) afterwards which does the pop.
That allows them to reuse the same #pragma pack code everywhere, which is handy as it may vary between compilers.
It's perfectly safe though. The #pragma push is followed by a pop, it's just included from a different file. So you should probably just disable that error.
OTHER TIPS
Yes, you'd get that from the #pragma pack directive in config/abi/msvc_prefix.hpp. It indicates that your project's default packing is not 8. That's pretty unusual, is this intentional? Bugs due to packing differences can be a bit tricky to diagnose.
I found a way to get rid of this warning.
You need to edit the file boost_1_**\boost\config\user.hpp and uncomment the line with BOOST_DISABLE_ABI_HEADERS
So you should be defining in this file:
#define BOOST_DISABLE_ABI_HEADERS
Once that is done, just build with bjam like you normally would.
Please see comments below for dangers of this solution