How do .so files avoid problems associated with passing header-only templates like MS dll files have?

Posted by Doug T. on Programmers See other posts from Programmers or by Doug T.
Published on 2012-11-21T15:43:19Z Indexed on 2012/11/21 17:15 UTC
Read the original article Hit count: 233

Filed under:
|
|
|
|

Based on the discussion around this question. I'd like to know how .so files/the ELF format/the gcc toolchain avoid problems passing classes defined purely in header files (like the std library). According to Jan in that answer, the dynamic linker/loader only picks one version of such a class to load if its defined in two .so files. So if two .so files have two definitions, perhaps with different compiler options/etc, the dynamic linker can pick one to use.

Is this correct? How does this work with inlining? For example, MSVC inlines templates aggressively. This makes the solution I describe above untenable for dlls. Does Gcc never inline header-only templates like the std library as MSVC does? If so wouldn't that make the functionality of ELF described above ineffective in these cases?

© Programmers or respective owner

Related posts about c++

Related posts about c++11