assume, assert, enforce, @safe

Johannes Pfau via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 1 08:11:23 PDT 2014


Am Fri, 1 Aug 2014 23:20:02 +1000
schrieb "Daniel Murphy" <yebbliesnospam at gmail.com>:

> "Johannes Pfau"  wrote in message
> news:lrfqqt$1jem$1 at digitalmars.com...
> 
> > Which symbols are
> > actually used in the final executable is up to the linker and not
> > standardized.
> 
> Isn't it?  dmd will set it up so the definitions in the library will
> only get pulled in if undefined, and this will usually mean any
> definitions in the main object files will override the library ones.
> It should work this way on all platforms.

Do you know if linkers actually guarantee that behaviour? AFAICS dmd
doesn't do anything special, it always emits weak symbols and just calls
gcc to link. The linker usually uses the first symbol it sees, but I
have not seen any guarantees for that.

Also what happens if your main application doesn't use the template,
but two libraries use the same template. Then which instances are
actually used? I'd guess those from the 'first' library?

> Of course, definitions in different object files will be subject to
> comdat folding and that is not standardized. 
> 



More information about the Digitalmars-d mailing list