Skip to content

Commit c4c2dc1

Browse files
committed
Issue 5337 - Documentation regarding interfacing with C does not account for TLS differences
1 parent f1f37fa commit c4c2dc1

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

interfaceToC.dd

+29-14
Original file line numberDiff line numberDiff line change
@@ -429,20 +429,6 @@ void foo(char[] string) {
429429
do the right shift and masks.
430430
)
431431

432-
$(V1
433-
<hr>
434-
<h1>Interfacing to C++</h1>
435-
436-
$(P D does not provide an interface to C++, other than
437-
through $(DPLLINK COM.html, COM programming). Since D, however,
438-
interfaces directly to C, it can interface directly to
439-
C++ code if it is declared as having C linkage.
440-
)
441-
442-
$(P D class objects are incompatible with C++ class objects.
443-
)
444-
)
445-
446432
<h2>$(LNAME2 Using C Libraries, Using Existing C Libraries)</h2>
447433

448434
$(P Since D can call C code directly, it can also call any C library
@@ -457,6 +443,35 @@ $(V1
457443
to the Deimos Project.
458444
)
459445

446+
<h2>$(LNAME2 C Globals, Accessing C Globals)</h2>
447+
448+
$(P C globals can be accessed directly from D. C globals have the C naming
449+
convention, and so must be in an $(D extern (C)) block.
450+
Use the $(D extern) storage class to indicate that the global is allocated
451+
in the C code, not the D code.
452+
$(V2 C globals default to being in global, not thread local, storage.
453+
To reference global storage
454+
from D, use the $(D __gshared) storage class.)
455+
)
456+
457+
---
458+
extern (C) extern __gshared int x;
459+
---
460+
461+
$(V1
462+
<hr>
463+
<h1>Interfacing to C++</h1>
464+
465+
$(P D does not provide an interface to C++, other than
466+
through $(DPLLINK COM.html, COM programming). Since D, however,
467+
interfaces directly to C, it can interface directly to
468+
C++ code if it is declared as having C linkage.
469+
)
470+
471+
$(P D class objects are incompatible with C++ class objects.
472+
)
473+
)
474+
460475
)
461476

462477
Macros:

0 commit comments

Comments
 (0)