digitalmars.D.bugs - [Issue 1306] New: extern (Windows) should work like extern (C) for variables
- d-bugmail puremagic.com (28/28) Jul 02 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1306
- d-bugmail puremagic.com (4/4) Jul 02 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1306
- d-bugmail puremagic.com (23/23) Jul 02 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1306
- d-bugmail puremagic.com (9/9) Jul 30 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1306
http://d.puremagic.com/issues/show_bug.cgi?id=1306 Summary: extern (Windows) should work like extern (C) for variables Product: D Version: 1.017 Platform: PC OS/Version: Windows Status: NEW Keywords: link-failure Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: torhu yahoo.com In some cases, extern (Windows) causes ' 0' to get added to the end of symbols that represent variables. This causes linking errors. I wasn't able to create a simple test case, but the problem should be clear. Scenario: I have a few hundred function pointers in a C library. To link with those, I have to use extern (C). But to actually call the functions, I need the function pointers to have type extern (Windows). Since extern (Windows) changes the mangling of the pointers, I can't link both link with the C library, and call the functions successfully. So I'm stuck, and probably need some ugly workaround. I compiled 'int __stdcall x;' with msvc 6, which it accepted with a warning. Looking at the object file, the symbol was not affected by __stdcall. So DMD's behavior is probably wrong. --
Jul 02 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1306 ------- Comment #1 from braddr puremagic.com 2007-07-02 10:33 ------- Please include a set of reproduction steps, including source code. --
Jul 02 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1306 ------- Comment #2 from torhu yahoo.com 2007-07-02 11:41 ------- I nailed, it's another problem with the export keyword. stdcall.d: --- export extern (Windows) void (*funcptr)(int); void main() { funcptr(5); } --- Just to show how funcptr gets mangled: c:\prog\test\D>dmd stdcall c:\prog\dmd\bin\..\..\dm\bin\link.exe stdcall,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved c:\prog\dmd\bin\..\lib\phobos.lib(dmain2) Error 42: Symbol Undefined _funcptr 0 --- errorlevel 1 funcptr is mangled as _funcptr 0, which I believe is a stdcall function of zero arguments. This is clearly wrong, and won't link with the corresponding C definition of the function pointer. --
Jul 02 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1306 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #3 from bugzilla digitalmars.com 2007-07-30 15:48 ------- Fixed DMD 1.019 and 2.003 --
Jul 30 2007