With DMD32 D Compiler v2.062, $ cat libA.d module libA; extern (C) { struct Opaque; // forward reference Opaque* getObject(); } $ cat libB.d module libB; extern (C) { struct Opaque; // forward reference void doAction(Opaque *); } $ cat bug.d import libA, libB; int main(string[] args) { auto opaque = libA.getObject(); libB.doAction(cast(libB.Opaque *)opaque); return 0; } $ rdmd bug.dlibB.d(5): Error: struct libB.Opaque unknown size libB.d(5): Error: struct libB.Opaque no size yet for forward reference libB.d(5): Error: struct libB.Opaque unknown size libB.d(5): Error: struct libB.Opaque no size yet for forward reference libA.d(5): Error: struct libA.Opaque unknown size libA.d(5): Error: struct libA.Opaque no size yet for forward reference Failed: 'dmd' '-v' '-o-' 'bug.d' '-I.' $ If we declare Opaque in a separate file and import it in libA and libB, then there is no compiler error. Also if we remove the cast in bug.d, the error message would be: bug.d(6): Error: function libB.doAction (Opaque*) is not callable using argument types (Opaque*) bug.d(6): Error: cannot implicitly convert expression (opaque) of type Opaque* to Opaque* The compiler should have qualified Opaque so that it is easier to understand that it cannot convert libA.Opaque* to libB.Opaque*
This is a dup of bug 10451. With 2.064 git-head, the OP code correctly reports link-time errors. $ dmd libA.d libB.d bug.d DMD v2.064 DEBUG OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html libA.obj(libA) Error 42: Symbol Undefined _getObject libA.obj(libA) Error 42: Symbol Undefined _doAction --- errorlevel 2 *** This issue has been marked as a duplicate of issue 10451 ***