std library hooks

Manu turkeyman at gmail.com
Sat Apr 14 16:54:16 PDT 2012


On 14 April 2012 22:40, Walter Bright <newshound2 at digitalmars.com> wrote:

> On 4/14/2012 2:40 AM, Vladimir Panteleev wrote:
>
>> So object files take priority over library files?
>>
>
> Yes, because object files are NOT searched. They are incorporated.
> Libraries get recursively searched for unresolved symbols.
>

I was under the impression library files were nothing more than a
collection of object files?


On 14 April 2012 22:44, Walter Bright <newshound2 at digitalmars.com> wrote:

> Is this also how ld and link.exe works?
>>
>
> It's how every linker I've ever used and heard of works.
>
> Keep in mind that an object file consists of blocks of BINARY data
> attached to symbols. There is no meaning in the binary data. The linker
> knows nothing about the meaning of that binary data, or where it came from.
> Run the "dumpobj" utility over an object file and you'll see what I mean.
>

I'm aware of how a linker works :) .. I wouldn't expect the linker to be
able to resolve multiply defined symbols though without instruction...

I just tried it, and I got the error I expected:

LIBCMTD.lib(atox.obj) : error LNK2005: _atoi already defined in Unit.obj

In C, I would always explicitly declare weak linkage to do this... what's
the point of the weak attribute if not for this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120415/18ded42e/attachment.html>


More information about the Digitalmars-d mailing list