Code fails with linker error. Why?

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 6 06:23:53 PDT 2014


On Monday, 6 October 2014 at 12:16:14 UTC, eles wrote:
> On Monday, 6 October 2014 at 11:54:56 UTC, John Colvin wrote:
>> On Monday, 6 October 2014 at 10:10:04 UTC, eles wrote:
>>> On Saturday, 4 October 2014 at 15:29:57 UTC, John Colvin 
>>> wrote:
>>>> On Saturday, 4 October 2014 at 11:19:52 UTC, ketmar via 
>>>> Digitalmars-d-learn wrote:
>>>>> On Sat, 04 Oct 2014 11:01:28 +0000
>>>>> John Colvin via Digitalmars-d-learn 
>>>>> <digitalmars-d-learn at puremagic.com>
>>>>> wrote:
>>>>>
>>>>>> On Saturday, 4 October 2014 at 10:38:32 UTC, ketmar via 
>>>>>> Digitalmars-d-learn wrote:
>>>>>> > On Sat, 04 Oct 2014 10:27:16 +0000
>>>>>> > John Colvin via Digitalmars-d-learn 
>>>>>> > <digitalmars-d-learn at puremagic.com>
>>>>>> > wrote:
>
>> I don't quite follow. Example?
>
> Well, in the OP example, imagine that I was trying to compile 
> this module along with another one that simply happened to have 
> a method defined in a way that the linker would have find it.
>
> I would have compiled with:
>
> dmd app.d app2.d
>
> and be unaware what bug I have introduced because I forgot do 
> declare formula() as abstract in the first class.

This isn't a problem. You're not going to get the name-mangling 
right by accident. Even for free functions the module name is 
mangled in.

The only way this can happen is with extern(C) functions, which 
is because C doesn't mangle it's function names.


More information about the Digitalmars-d-learn mailing list