diff --git a/src/ddmd/dclass.d b/src/ddmd/dclass.d index d4fa922e01ab..868109081c50 100644 --- a/src/ddmd/dclass.d +++ b/src/ddmd/dclass.d @@ -423,15 +423,10 @@ extern (C++) class ClassDeclaration : AggregateDeclaration auto sc2 = super.newScope(sc); if (isCOMclass()) { - if (global.params.isWindows) - sc2.linkage = LINKwindows; - else - { - /* This enables us to use COM objects under Linux and - * work with things like XPCOM - */ - sc2.linkage = LINKc; - } + /* This enables us to use COM objects under Linux and + * work with things like XPCOM + */ + sc2.linkage = Target.systemLinkage(); } return sc2; } diff --git a/src/ddmd/parse.d b/src/ddmd/parse.d index 7cc3ecb80b56..889f9b85c53e 100644 --- a/src/ddmd/parse.d +++ b/src/ddmd/parse.d @@ -21,6 +21,7 @@ import ddmd.root.filename; import ddmd.root.outbuffer; import ddmd.root.rmem; import ddmd.root.rootobject; +import ddmd.target; import ddmd.tokens; // How multiple declarations are parsed. @@ -2193,7 +2194,7 @@ final class Parser(AST) : Lexer } else if (id == Id.System) { - link = global.params.isWindows ? LINKwindows : LINKc; + link = Target.systemLinkage(); } else { diff --git a/src/ddmd/target.d b/src/ddmd/target.d index 735e7e3eb4e9..cc6f2041bc72 100644 --- a/src/ddmd/target.d +++ b/src/ddmd/target.d @@ -442,6 +442,7 @@ struct Target else static assert(0, "fix this"); } + extern (C++) static const(char)* cppTypeInfoMangle(ClassDeclaration cd) { static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS) @@ -451,6 +452,14 @@ struct Target else static assert(0, "fix this"); } + + /** + * Return the default system linkage for the target. + */ + extern (C++) static LINK systemLinkage() + { + return global.params.isWindows ? LINKwindows : LINKc; + } } /******************************