Skip to content

Commit e9e831d

Browse files
authored
clarify difference between declaration and definition (#3629)
1 parent 0ad417b commit e9e831d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

spec/attribute.dd

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,22 @@ $(H3 $(LNAME2 export, $(D export) Attribute))
429429
or DLL.)
430430

431431
$(P $(D export) applied to the definition of a symbol will export it. $(D export) applied to
432-
a declaration of a symbol will import it.)
432+
a declaration of a symbol will import it.
433+
A variable is a definition unless `extern` is applied to it.)
433434

434435
---
435436
export int x = 3; // definition, exporting `x`
436437
export int y; // definition, exporting `y`
437438
export extern int z; // declaration, importing `z`
439+
440+
export __gshared h = 3; // definition, exporting `h`
441+
export __gshared i; // definition, exporting `i`
442+
export extern __gshared int j; // declaration, importing `j`
443+
---
444+
445+
$(P A function with a body is a definition, without a body is a declaration.)
446+
447+
---
438448
export void f() { } // definition, exporting `f`
439449
export void g(); // declaration, importing `g`
440450
---

0 commit comments

Comments
 (0)