4

I found, the hard way, that at least boost::program_options is dependent of the compiler configured structure member alignment.

If you build boost using default settings and link it with a project using 4 bytes alignment (/Zp4) it will fail at runtime (made a minimal test with program_options). Boost will generate an assert indicating a possible bad calling convention but the real reason is the structure member alignment.

Is there any way to prevent this? If the alignment makes the code incompatible shouldn't this be included in library naming?

Community
  • 1
  • 1
sorin
  • 161,544
  • 178
  • 535
  • 806
  • You know, there are *a lot* of compiler options that alter the ABI. They can't all be named. Sometimes, even Boost developers have to assume that their users are competent and know how to link to a library – jalf Apr 26 '10 at 09:21
  • 1
    Are you compiling the program options lib yourself? Or using a prebuilt? If you can provide the test case we'd, i.e. Vladimir P., love to debug it. Because as long as *all* the code is compile with compatible options things should not break. – GrafikRobot Apr 26 '10 at 13:33

1 Answers1

8

You need to ensure that your program and the libraries you link with have the same ABI.

The number of compiler switches that can alter the ABI of C++ classes and functions could be too large so it is clearly a problem to name more than 3000 combinations.

You could take a look here for a more detailed rationale.

Vicente Botet Escriba
  • 4,305
  • 1
  • 25
  • 39