@@ -429,20 +429,6 @@ void foo(char[] string) {
429
429
do the right shift and masks.
430
430
)
431
431
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
-
446
432
<h2>$(LNAME2 Using C Libraries, Using Existing C Libraries)</h2>
447
433
448
434
$(P Since D can call C code directly, it can also call any C library
@@ -457,6 +443,35 @@ $(V1
457
443
to the Deimos Project.
458
444
)
459
445
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
+
460
475
)
461
476
462
477
Macros:
0 commit comments