Skip to content

Commit 0f7681b

Browse files
ntreldlang-bot
authored andcommitted
[spec/importc] Tweak docs
Add some inline code formatting. CCODE can't be inside a P invocation. Use RELATIVE_LINK2 for non-HTML targets. Remove duplicate `__buildins.di` heading.
1 parent 6122392 commit 0f7681b

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

spec/importc.dd

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ $(H2 $(LNAME2 preprocessor-directives, Preprocessor Directives))
318318
$(P $(LINK2 https://gcc.gnu.org/onlinedocs/gcc-11.1.0/cpp/Preprocessor-Output.html, linemarker)
319319
directives are normally embedded in the output of C preprocessors.)
320320

321-
$(H3 $(LNAME2 pragma, pragma))
321+
$(H3 $(LNAME2 pragma, Pragmas))
322322

323323
$(P The following pragmas are supported:)
324324

@@ -333,7 +333,7 @@ $(H2 $(LNAME2 preprocessor-directives, Preprocessor Directives))
333333
$(LI $(TT #pragma pack ( pop PopList )))
334334
)
335335

336-
$(H4 $(LNAME2 pragma-attribute, pragma attribute))
336+
$(H4 $(LNAME2 pragma-attribute, `#pragma attribute`))
337337

338338
The following pragma for ImportC allows to set default storage
339339
classes for function declarations:
@@ -411,7 +411,7 @@ int main()
411411
$(RATIONALE Implicit function declarations are very error-prone and cause hard
412412
to find bugs.)
413413

414-
$(H3 $(LNAME2 pragma-STDC-FENV_ACCESS, #pragma STDC FENV_ACCESS))
414+
$(H3 $(LNAME2 pragma-STDC-FENV_ACCESS, `#pragma STDC FENV_ACCESS`))
415415

416416
$(P This is described in C11 7.6.1)
417417

@@ -436,13 +436,17 @@ $(H2 $(LNAME2 limitations, Limitations))
436436
$(H3 $(LNAME2 const, Const))
437437

438438
$(P C11 specifies that `const` only applies locally. `const` in ImportC applies transitively,
439-
meaning that although $(CCODE int *const p;) means in C11 that `p` is a const pointer to `int`,
439+
meaning that although:)
440+
441+
$(CCODE int *const p;)
442+
443+
$(P means in C11 that `p` is a const pointer to `int`,
440444
in ImportC it means `p` is a `const` pointer to a `const int`.)
441445

442446
$(H3 $(LNAME2 volatile, Volatile))
443447

444448
$(P The `volatile` type-qualifier (C11 6.7.3) is ignored. Use of `volatile` to implement shared
445-
memory access is unlikely to work anyway, $(LINK2 #_atomic, _Atomic) is for that.
449+
memory access is unlikely to work anyway, $(RELATIVE_LINK2 _atomic, _Atomic) is for that.
446450
To use `volatile` as a device register, call a function to do it that is compiled separately,
447451
or use inline assembler.
448452
)
@@ -451,7 +455,7 @@ $(H2 $(LNAME2 limitations, Limitations))
451455

452456
$(P The `restrict` type-qualifier (C11 6.7.3) is ignored.)
453457

454-
$(H3 $(LNAME2 _atomic, _Atomic))
458+
$(H3 $(LNAME2 _atomic, `_Atomic`))
455459

456460
$(P The `_Atomic` type-qualifier (C11 6.7.3) is ignored.
457461
To do atomic operations, use an externally compiled function for that, or the inline assembler.)
@@ -499,14 +503,14 @@ struct S { int version; };)
499503

500504
$(P On some platforms, C `long` and `unsigned long` are the same size as `int` and `unsigned int`, respectively.
501505
On other platforms, C `long` and `unsigned long` are the same size as `long long` and `unsigned long long`.
502-
`long double` and `long double _Complex` can be same size as `double` and `double _Complex`.
506+
`long double` and `long double _Complex` can be the same size as `double` and `double _Complex`.
503507
In ImportC, these types that are the same size and signed-ness are treated as the same types.
504508
)
505509

506-
$(H3 $(LNAME2 _generic, _Generic))
510+
$(H3 $(LNAME2 _generic, `_Generic`))
507511

508512
$(P $(B Generic selection) expressions (C11 6.5.1.1) differ from ImportC.
509-
The types in $(LINK2 #same_only_different, Same only Different Types) are
513+
The types in $(RELATIVE_LINK2 same_only_different, Same only Different Types) are
510514
indistinguishable in the $(I type-name) parts of $(I generic-association).
511515
Instead of giving an error for duplicate types per C11 6.5.1.1-2, ImportC
512516
will select the first compatible $(I type-name) in the $(I generic-assoc-list).
@@ -643,7 +647,7 @@ _Static_assert(sizeof(A) == 1, "A should be size 1");
643647
$(P Arrays can have `register` storage class, and may be enregistered by the compiler. C11 6.3.2.1-3)
644648

645649

646-
$(H3 $(LNAME2 typeof, typeof Operator))
650+
$(H3 $(LNAME2 typeof, `typeof` Operator))
647651

648652
$(P The `typeof` operator may be used as a type specifier:)
649653
$(INFORMATIVE_GRAMMAR
@@ -672,7 +676,7 @@ $(GNAME CImportDeclaration):
672676
)
673677

674678
$(P Imports also enable ImportC code to directly import other C files without
675-
needing to create a .h file for them, either.
679+
needing to create a `.h` file for them, either.
676680
Imported C functions become available to be inlined.
677681
)
678682

@@ -730,13 +734,13 @@ enum E { A = 3; }
730734

731735
$(P A control-Z character `\x1A` in the source text means End Of File.)
732736

733-
$(H3 $(LNAME2 largeDecimal, Signed Integer Literal Larger Than long long))
737+
$(H3 $(LNAME2 largeDecimal, Signed Integer Literal Larger Than `long long`))
734738

735739
$(P A signed integer constant with no suffix that is larger than a `long long` type,
736740
but will fit into an `unsigned long long` type, is accepted and typed as `unsigned long long`.
737741
This matches D behavior, and that of some C compilers.)
738742

739-
$(H3 $(LNAME2 dotArrow, Dot and Arror Operators))
743+
$(H3 $(LNAME2 dotArrow, Dot and Arrow Operators))
740744

741745
$(P The `.` operator is used to designate a member of a struct or union value.
742746
The `->` operator is used to designate a member of a struct or union value pointed to
@@ -782,7 +786,7 @@ size_t x = sizeof(foo());)
782786

783787
$(P This code is accepted by `gcc`, but makes no sense for D. Hence,
784788
although it works in ImportC, it is not representable as D code,
785-
meaning one must use judgement in creating a .di file to interface
789+
meaning one must use judgement in creating a `.di` file to interface
786790
with C `noreturn` functions.)
787791

788792
$(P Furthermore, the D compiler takes advantage of `noreturn` functions
@@ -999,12 +1003,6 @@ $(H2 $(LNAME2 warnings, Warnings))
9991003
If C11 says it is legal, ImportC accepts it.)
10001004

10011005

1002-
$(H2 $(LNAME2 builtins, $(TT __builtins.di)))
1003-
1004-
$(P ImportC uses D to implement several features. These are implemented in the file
1005-
$(LINK2 https://github.com/dlang/dmd/blob/master/druntime/src/__builtins.di, $(TT __builtins.di))
1006-
which is automatically imported for every ImportC compilation.)
1007-
10081006
$(H2 $(LNAME2 importcpp, ImportC++))
10091007

10101008
$(P ImportC will not compile C++ code. For that, use $(TT dpp).)
@@ -1021,7 +1019,7 @@ $(H2 $(LNAME2 other-solutions, Other Solutions))
10211019
$(P From the Article:)
10221020

10231021
$(BLOCKQUOTE dpp is a compiler wrapper that will parse a D source
1024-
file with the .dpp extension and expand in place any #include directives
1022+
file with the `.dpp` extension and expand in place any `#include` directives
10251023
it encounters, translating all of the C or C++ symbols to D, and then
10261024
pass the result to a D compiler (DMD by default).)
10271025

@@ -1063,7 +1061,7 @@ $(H2 $(LNAME2 internals, How ImportC Works))
10631061
$(P This co-opting of the D semantic implementation allows ImportC to be able to do things
10641062
like handle forward references, CTFE (Compile Time Function Execution), and inlining of C functions
10651063
into D code. Being able to handle forward references means it is not necessary to even
1066-
write a .h file to be able to import C declarations into D. Being able to perform CTFE is
1064+
write a `.h` file to be able to import C declarations into D. Being able to perform CTFE is
10671065
very handy for testing that ImportC is working without needing to generate an executable.
10681066
But, in general, the strong temptation to add D features to ImportC has been resisted.)
10691067

0 commit comments

Comments
 (0)