Issue 9302 - Extern is used both as a storage class and as a linkage attribute #237

merged 1 commit into from Jan 12, 2013

2 participants

@alexrp alexrp commented on an outdated diff Jan 12, 2013
@@ -550,6 +550,19 @@ b = 4; // sets S.i to 4
The primary usefulness of this is to connect with global
variable declarations in C files.
+ $(P An $(B extern) declaration can optionally be followed by an
+ $(B extern) $(LINK2 attribute.html#linkage, linkage attribute).
+ If there is no linkage attribute it defaults to $(B extern(D)):)
+extern(C) int foo; // variable allocated and initialized in this module with C linkage
+extern extern(C) int bar; // variable allocated outside this module with C linkage
+ // (e.g. in a statically linked C library or another module)
+extern extern(D) int doo1; // variable allocated outside this module with D linkage
alexrp Jan 12, 2013 D Programming Language member

I don't think this particular example serves any useful purpose since module variables with D linkage are mangled with the module name...


@alexrp: Yeah I added it for completeness sake, but I can see how C programmers might get confused when they start getting linkage failures. Removed that example.

@alexrp alexrp merged commit eee1cd8 into dlang:master Jan 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment