Bug 2106 – export class doesn't affect, what is exported

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-05-14T02:58:00Z
Last change time
2015-06-09T01:19:25Z
Keywords
link-failure
Assigned to
nobody
Creator
the.yossarian

Comments

Comment #0 by the.yossarian — 2008-05-14T02:58:51Z
the export modifier on class doesn't work as excepted. export class A { export public void function(); } export class B : A { public void function2(); } this code exports ONLY A.function(); ( i checked DLL with objdump ) the following throws undefined error when linking: B b = new B(); A a = cast(A)b; Error 42: Symbol Undefined _D4test1A1A7__ClassZ .....
Comment #1 by torhu — 2008-05-14T05:39:32Z
(In reply to comment #0) > the export modifier on class doesn't work as excepted. > > export class A { export public void function(); } > export class B : A { public void function2(); } > > this code exports ONLY A.function(); ( i checked DLL with objdump ) I haven't tried getting classes inside DLLs to work myself. But you should probably provide a complete, compilable, minimal test case. > > the following throws undefined error when linking: > > B b = new B(); > A a = cast(A)b; Do you need both lines to trigger the error, isn't the first one enough?
Comment #2 by the.yossarian — 2008-05-14T06:33:54Z
ok, the first is enough. test case: --- dll.d --- module dll; export class A { export void func() { } } --- test.d --- import dll; int main() { A a = new A(); return 0; } --- make.bat --- dmd -ofdll.dll dll.d phobos.lib dmd -oftest.exe test.d phobos.lib dies with: test.obj(test) Error 42: Symbol Undefined _D3dll1A7__ClassZ
Comment #3 by bugzilla — 2012-01-22T01:40:12Z
The problem is an export record isn't generated for the _ClassZ. It's a compiler bug, not a spec issue.
Comment #4 by github-bugzilla — 2012-01-22T10:15:21Z
Comment #5 by github-bugzilla — 2012-01-22T10:15:35Z