views:

182

answers:

3

What harm can come from defining BOOST_DISABLE_ABI_HEADERS when compiling boost?

From the boost file: boost_1_37_0\boost\config\user.hpp

// BOOST_DISABLE_ABI_HEADERS: Stops boost headers from including any 
// prefix/suffix headers that normally control things like struct 
// packing and alignment. 
//#define BOOST_DISABLE_ABI_HEADERS

Why does boost feel the need to control struct packing and alignment?

Does it maybe have to do with boost serialization and making sure it works the same on all platforms? If I'm running windows only, can I safely define this?

+2  A: 

The define assures that the ABI (application binary interface) stays compatible between versions and compilers. Without that, your application could not use the boost dlls installed by another application (which might have been compiled with a different compiler than yours).

If you're linking statically to boost or if you can assure that your app only uses the boost dlls you compiled yourself for it, then yes, you can safely define this. However if you can't assure that, you must not define it.

Stefan
+1  A: 

Here's what I could find on the Boost docs: http://www.boost.org/doc/libs/1_31_0/libs/config/config.htm

It's for a fairly old version, but presumably, the meaning of the #define hasn't changed.

jalf
A: 

Here is a rundown of defining BOOST_DISABLE_ABI_HEADERS:

  • If you use some shared boost dlls, you will get undefined behavior
  • If you statically link to your boost libraries, or you are sure you are only using your own dlls then you may be safe, keep reading for why I say may.
  • If you use boost in several .libs in your project they must all have the same compiler settings as a change in a compiler setting can make the packing and alignment different.
  • I would suspect that compatibility between different OS and platforms (x86 vs x64) may not work for things like boost serialization.

Overall it's not very safe to define this and much safer to leave it alone.

Brian R. Bondy