Russell Hind wrote:
I have built the boost::signals library with C++Builder 6 Pro Update 4 and am running into problems:
[...]
b) If I do use quad word alignment, then the object constructs correctly, but when I connect a method to it with
void VoidFunc(void) { }
int main(int argc, char* argv[]) { boost::signal0<void> s; s.connect(&VoidFunc); }
the program hangs. Turning on CodeGuard shows a similar problem to that above. The object was allocated with a size of 12 bytes, but code is trying to access byte 16 in the object (I guess this is a similar alignment problem). The callstack is
0041E44E boost::counted_base::dispose(this=:00C04360)
counted_base::dispose() is an empty function, so this looks like a CodeGuard false alarm. One possible reason for the real problem is runtime library mismatch between the signals library and your executable. counted_base contains a mutex in multithreaded builds.
Do (or should) all the bost headers force alignment before all structures/classes and then restore the alignment afterwards?
No. The compiler options used to build the application and the libraries it depends on must match. The headers cannot magically fix the (general) problem for you; even if we focus on one particular compiler/platform - and we shouldn't - some of the options are global.
Currently, I have to link directly with the signals source code to get use the library.
This is what I'd do, too. The other alternative is to build several .lib files that match the options specified in your various project configurations (Debug, Debug MT, Release, Release MT, or however their canonical names are in BCB).