[Issue 1830] New: duplicated constants + extern(Windows) = Link error: Previous Definition Different
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 12 21:57:26 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1830
Summary: duplicated constants + extern(Windows) = Link error:
Previous Definition Different
Product: D
Version: 1.025
Platform: PC
OS/Version: Windows
Status: NEW
Keywords: link-failure
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: wbaxter at gmail.com
If two modules define the same constants it's usually OK. But if those
constants are extern(windows) then they will create linker errors.
---link_main.d---
module link_main;
import link_a;
import link_b;
void main()
{
}
---link_a.d---
module link_a;
extern(Windows):
const uint FOO = cast(uint)-1;
---link_b.d---
module link_b;
extern(Windows):
const uint FOO = cast(uint)-1;
---
Build with
dmd link_main link_a link_b
And you get:
"""
f:\usr\pkg\d\dmd\bin\..\..\dm\bin\link.exe
link_main+link_a+link_b,,,user32+kernel32/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
link_b.obj(link_b) Offset 000E0H Record Type 0091
Error 1: Previous Definition Different : _FOO
--- errorlevel 1
"""
If you remove the extern(Windows) lines, it links fine.
This is causing trouble when linking apps that import more than one Windows API
wrapper since most of them stick an extern(Windows): at the top of the file,
which ends up covering all the constants as well as functions. I'm not even
sure if extern(Windows) has meaning for constants like that, but it certainly
appears to influence how the linker handles them.
--
More information about the Digitalmars-d-bugs
mailing list