Skip to content

Commit 301db73

Browse files
authored
Merge pull request #3506 from WalterBright/export
expound on what export means
2 parents a4e799b + b3aebda commit 301db73

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

spec/attribute.dd

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ $(P Visibility is an attribute that is one of $(D private), $(D package),
405405
`protected`, $(D public), or $(D export). They may be referred to as protection
406406
attributes in documents predating $(LINK2 http://wiki.dlang.org/DIP22, DIP22).)
407407

408+
$(P Visibility participates in $(DDSUBLINK spec/module, name_lookup, symbol name lookup).
409+
)
410+
408411
$(P Symbols with $(D private) visibility can only be accessed from
409412
within the same module.
410413
Private member functions are implicitly $(DDSUBLINK spec/function, final, `final`)
@@ -436,12 +439,26 @@ attributes in documents predating $(LINK2 http://wiki.dlang.org/DIP22, DIP22).)
436439
It is the default visibility attribute.
437440
)
438441

439-
$(P $(D export) means that any code outside the executable can access the
440-
member. $(D export) is analogous to exporting definitions from a DLL.
441-
)
442+
$(H3 $(LNAME2 export, $(D export) Attribute))
442443

443-
$(P Visibility participates in $(DDSUBLINK spec/module, name_lookup, symbol name lookup).
444-
)
444+
$(P $(D export) means that a symbol can be accessed from outside the executable,
445+
shared library, or DLL. The symbol is said to be exported from where it is defined
446+
in an executable, shared library, or DLL, and imported by another executable, shared library,
447+
or DLL.)
448+
449+
$(P $(D export) applied to the definition of a symbol will export it. $(D export) applied to
450+
a declaration of a symbol will import it.)
451+
452+
---
453+
export int x = 3; // definition, exporting `x`
454+
export int y; // definition, exporting `y`
455+
export extern int z; // declaration, importing `z`
456+
export void f() { } // definition, exporting `f`
457+
export void g(); // declaration, importing `g`
458+
---
459+
460+
$(P In Windows terminology, $(I dllexport) means exporting a symbol from a DLL, and $(I dllimport) means
461+
a DLL or executable is importing a symbol from a DLL.)
445462

446463

447464
$(H2 $(LNAME2 const, $(D const) Attribute))

0 commit comments

Comments
 (0)