Automatically call `dcm_init()` when built with MSVC
bgilbert opened this issue · 0 comments
bgilbert commented
It's awkward that libdicom automatically initializes itself in a thread-safe way, except when compiled on one major compiler for one major platform. While __attribute__((constructor))
doesn't exist on MSVC, equivalent functionality is available.
One approach is to handle DLL_PROCESS_ATTACH
in DllMain()
, but that doesn't work when statically linked. The more general approach is to put an initializer in a .CRT$XCU
section (example), though there are subtleties to prevent the constructor from being GCed during LTO. glib uses this latter mechanism.