Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

1 participant

declaration.dd
@@ -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 Collaborator
alexrp added a note

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ghost

@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 from
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 12, 2013
  1. Fixes Issue 9302 - Extern is used both as a storage class and as a li…

    Andrej Mitrovic authored
    …nkage attribute.
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 3 deletions.
  1. +4 −1 attribute.dd
  2. +13 −2 declaration.dd
View
5 attribute.dd
@@ -14,7 +14,7 @@ $(GNAME Attribute):
$(LINK2 #deprecated, $(B deprecated))
$(GLINK ProtectionAttribute)
$(B static)
- $(B extern)
+ $(LINK2 #linkage, $(B extern))
$(B final)
$(B synchronized)
$(LINK2 #override, $(B override))
@@ -116,6 +116,9 @@ extern (Windows):
);
---------------
+ $(P Note that a lone $(B extern) declaration is used as a
+ $(LINK2 declaration.html#extern, storage class).)
+
<h2>$(LNAME2 align, Align Attribute)</h2>
$(GRAMMAR
View
15 declaration.dd
@@ -130,7 +130,7 @@ $(V1 $(B const)
)$(V2 $(GLINK TypeCtor)
) $(B deprecated)
$(V2 $(B enum)
-) $(B extern)
+) $(LINK2 #extern, $(B extern))
$(B final)
$(V2 $(B nothrow)
$(B override)
@@ -550,6 +550,17 @@ 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)
+---------------
+
+
<h3><a name="typeof">typeof</a></h3>
$(GRAMMAR
@@ -605,7 +616,7 @@ $(V2
)
)
)
-
+
--------------------
class A { }
Something went wrong with that request. Please try again.