Name mangling problem with tiny Windows 10 load-time DLL example
WhatMeWorry
kheaser at gmail.com
Sun Feb 28 18:29:11 UTC 2021
It seems pretty obvious the problem is with name mangling. But
how to fix it?
------------------------------------------------------------------
module file;
extern(D) export
{
int addOne(int i) { return (i + 1); }
}
------------------------------------------------------------------
module patron;
import file;
void main()
{
import std.stdio;
int n = 1;
writeln("mangled name of addOne is ", addOne.mangleof);
numb = addOne(numb);
}
------------------------------------------------------------------
ldc2 -m64 -c file.d
ldc2 -m64 -c patron.d
ldc2 -m64 -shared file.obj -ofloadTime.dll
Creating library loadTime.lib and object loadTime.exp
Both dumpbin /exports loadTime.lib and dumpbin /exports
loadTime.dll
shows: _D4file6addOneFiZi
ldc2 patron.obj loadTime.lib
patron.exe
mangled name of addOne is _D6patron6addOneFiZi
// and library function is never called. Does not abend though???
-------------------------------------------------------------------
So the library function is named _D4file6addOneFiZi while the
user wants to call _D6patron6addOneFiZi
So which name is "correct" and how do I get them to agree with
each other?
More information about the Digitalmars-d-learn
mailing list