Should I force the library depending on the alignment of structural elements?

I found the hard way that at least boost::program_options depends on the alignment of the structure member configured by the compiler.

If you increase the forcing using the default settings and associate it with the project using 4-byte alignment ( /Zp4 ), it will work at runtime (did a minimal test using program_options). Boost will generate a statement indicating a possible convention of the wrong call, but the real reason is the alignment of the structure.

Is there any way to prevent this? If alignment makes the code incompatible, should this not be included in library names?

+4
source share
1 answer

You need to make sure that your program and the libraries you link to have the same ABI.

The number of compiler switches that can change ABI classes and functions of C ++ classes may be too large, so more than 3000 combinations are clearly worth mentioning.

You can look here for a more detailed justification.

+8
source

Source: https://habr.com/ru/post/1307990/


All Articles