Search code examples
c++boostpackingbjam

What harm can come from defining BOOST_DISABLE_ABI_HEADERS when compiling boost?


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?


Solution

  • 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.