Compile this file with the x64 MC compiler: // testcpp.cpp class ClassDeclaration { }; extern ClassDeclaration* ti2; class Type { public: static ClassDeclaration* typeinfovector; }; ClassDeclaration* foo() { return ti2 ? ti2 : Type::typeinfovector; } and link with // test.d extern(C++) class ClassDeclaration { } extern(C++) class Type { static __gshared ClassDeclaration typeinfovector; } extern(C++) __gshared ClassDeclaration ti2; extern(C++) ClassDeclaration* foo(); void main() { foo(); } /////////////////// cl /c testcpp.cpp dmd -m64 test.d testcpp.obj test.obj : error LNK2019: unresolved external symbol "class ClassDeclaration * * __cdecl foo(void)" (?foo@@YAPEAPEAVClassDeclaration@@XZ) referenced in function _Dmain testcpp.obj : error LNK2019: unresolved external symbol "class ClassDeclaration * ti2" (?ti2@@3PEAVClassDeclaration@@EA) referenced in function "class ClassDecl aration * __cdecl foo(void)" (?foo@@YAPEAVClassDeclaration@@XZ) testcpp.obj : error LNK2019: unresolved external symbol "public: static class Cl assDeclaration * Type::typeinfovector" (?typeinfovector@Type@@2PEAVClassDeclarat ion@@EA) referenced in function "class ClassDeclaration * __cdecl foo(void)" (?f oo@@YAPEAVClassDeclaration@@XZ) The dmd generated symbols are missing the "E" modifier for the pointer type: ?ti2@@3PEAVClassDeclaration@@A ?typeinfovector@Type@@2PEAVClassDeclaration@@A
https://github.com/D-Programming-Language/dmd/pull/4935
>extern(C++) ClassDeclaration* foo(); This is wrong, should not have the '*': >extern(C++) ClassDeclaration foo();
Commit pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d16e409431c6a73af8f4a92f512de1976f615b51 Merge pull request #4935 from rainers/issue14951 Fix issue 14951 - VC mangling for class reference/pointer
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d16e409431c6a73af8f4a92f512de1976f615b51 Merge pull request #4935 from rainers/issue14951
not automatically closed.