tags:

views:

659

answers:

3

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.

+4  A: 

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.

jalf
+2  A: 

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.

Hans Passant
A: 

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

Brian R. Bondy
Doesn't that mean it never enables packing? Seems like that could introduce a lot of fun errors.
jalf
It is safe if you are using your own boost dlls only or if you are statically linking. See here: http://stackoverflow.com/questions/410981/what-harm-can-come-from-defining-boostdisableabiheaders-when-compiling-boost#410992
Brian R. Bondy
Still seems like a lot of trouble (and a source of potential bugs) to go to just to eliminate a warning. I think you'd be better off just disabling that warning. With the #define, if you compile boost with just slightly different compiler flags than the rest of your code, fun crashes ensue.
jalf
You should also ensure that all projects that you use have the same build settings. Exmaple if you have a .lib. I agree with you overall though, I'm going to re-compile without this define. I'll keep this post though for history so people can see.
Brian R. Bondy