
5 Sep
2011
5 Sep
'11
11:40 a.m.
On 01/09/2011 19:00, Andrey Semashev wrote:
Suppose you use boost::any with types int and string in your main executable and in one of the dlls linked in. Exe and dll will have separate instances of both type_id<int>::value and type_id<string>::value
Which is no different than when compiling multiple translation units.
Depending on the circumstances, type_id<int>::value in exe may become initialized equal to type_id<string>::value in dll, for instance.
In practice, a good linker is supposed to remove duplicate weak symbols.
In practice, I'm aware of only one platform (Linux), which will by default attempt to maintain a single instance of these ids, but even there care must be taken.
Quite the opposite, only DLLs don't support weak symbols.