digitalmars.D.learn - Name mangling problem with tiny Windows 10 load-time DLL example
- WhatMeWorry (37/37) Feb 28 2021 It seems pretty obvious the problem is with name mangling. But
- Kagamin (1/1) Feb 28 2021 mangleof should give _D4file6addOneFiZi, not _D6patron6addOneFiZi
- Siemargl (6/9) Feb 28 2021 and your example work correct
- WhatMeWorry (8/18) Feb 28 2021 I double checked my posting and of course works it now works!?!?
- Siemargl (21/42) Mar 01 2021 Win10. Just try delete all obj, dll, lib and do full recompile
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?
Feb 28 2021
mangleof should give _D4file6addOneFiZi, not _D6patron6addOneFiZi
Feb 28 2021
On Sunday, 28 February 2021 at 18:29:11 UTC, WhatMeWorry wrote:It seems pretty obvious the problem is with name mangling. But how to fix it?fixingint numb = 1;and your example work correct ldc 1.24 / win10 P.S.I'm not recommend using such keywords as 'file', may cross with other modules.
Feb 28 2021
On Sunday, 28 February 2021 at 22:10:21 UTC, Siemargl wrote:On Sunday, 28 February 2021 at 18:29:11 UTC, WhatMeWorry wrote:I double checked my posting and of course works it now works!?!? I've been having trouble where it works and then it doesn't. I've been using examples with file.d, file1.d, file2.d, etc. I also came across the note that Windows file system is not case sensitive. Or is that case in-sensitive? This worked fine for Linux (Ubuntu) so you might be on to something.It seems pretty obvious the problem is with name mangling. But how to fix it?fixingint numb = 1;and your example work correct ldc 1.24 / win10 P.S.I'm not recommend using such keywords as 'file', may cross with other modules.
Feb 28 2021
On Sunday, 28 February 2021 at 23:00:56 UTC, WhatMeWorry wrote:On Sunday, 28 February 2021 at 22:10:21 UTC, Siemargl wrote:Win10. Just try delete all obj, dll, lib and do full recompile from scratch. module patron; import file; void main() { import std.stdio; int numb = 1; writeln("mangled name of addOne is ", addOne.mangleof); numb = addOne(numb); writeln(numb); } --------- E:\VSProjects\testjunk\D_load_dll>patron.exe mangled name of addOne is _D4file6addOneFiZi 2On Sunday, 28 February 2021 at 18:29:11 UTC, WhatMeWorry wrote:I double checked my posting and of course works it now works!?!? I've been having trouble where it works and then it doesn't. I've been using examples with file.d, file1.d, file2.d, etc. I also came across the note that Windows file system is not case sensitive. Or is that case in-sensitive? This worked fine for Linux (Ubuntu) so you might be on to something.It seems pretty obvious the problem is with name mangling. But how to fix it?fixingint numb = 1;and your example work correct ldc 1.24 / win10 P.S.I'm not recommend using such keywords as 'file', may cross with other modules.
Mar 01 2021