Skip to content

Commit 4964b04

Browse files
authored
Merge pull request #3530 from ibuclaw/importcasm
fix Issue 23716 - Document asm extension for ImportC
2 parents 2ad89d7 + 55d7504 commit 4964b04

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

spec/importc.dd

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,31 @@ $(H2 $(LNAME2 limitations, Limitations))
390390

391391
$(H2 $(LNAME2 extensions, Extensions))
392392

393+
$(H3 $(LNAME2 asmstatements, Asm statement))
394+
395+
$(P For the D language, `asm` is a standard keyword, and its construct is
396+
shared with ImportC. For the C language, `asm` is an extension (J.5.10),
397+
and the recommendation is to instead use `__asm__`. All alternative
398+
keywords for `asm` are translated by the druntime file $(TT src/importc.h)
399+
during the preprocessing stage.)
400+
401+
$(P The `asm` keyword may be used to embed assembler instructions, its
402+
syntax is implementation defined. The Digital Mars D compiler only supports
403+
the dialect of inline assembly as described in the documentation of the
404+
$(LINK2 https://dlang.org/spec/iasm.html, D x86 Inline Assembler).)
405+
406+
$(P `asm` in a function or variable declaration may be used to specify the
407+
mangle name for a symbol. Its use is analogous to
408+
$(LINK2 https://dlang.org/spec/pragma.html#mangle, pragma mangle).)
409+
410+
$(CCODE
411+
char **myenviron asm("environ") = 0;
412+
413+
int myprintf(char *, ...) asm("printf");
414+
)
415+
416+
$(P Using `asm` to associate registers with variables is ignored.)
417+
393418
$(H3 $(LNAME2 forward-references, Forward References))
394419

395420
$(P Any declarations in scope can be accessed, not just

0 commit comments

Comments
 (0)