Skip to content

Commit f7f8b13

Browse files
WalterBrightdlang-bot
authored andcommitted
ImportC: document __declspec and __attribute__ extensions
1 parent 71c8fa2 commit f7f8b13

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

spec/importc.dd

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,23 @@ $(H2 $(LNAME2 gnu-clang-extensions, Gnu and Clang Extensions))
600600
$(P `gcc` and `clang` are presumed to have the same behavior w.r.t. extensions,
601601
so `gcc` as used here refers to both.)
602602

603+
604+
$(H3 $(LNAME2 __attribute__, `__attribute__` Extensions))
605+
606+
$(P The following $(LINK2 https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html, `__attribute__` extensions):)
607+
608+
$(OL
609+
$(LI `__attribute__((aligned(N)))`)
610+
$(LI `__attribute__((always_inline))`)
611+
$(LI `__attribute__((deprecated))`)
612+
$(LI `__attribute__((dllexport))`)
613+
$(LI `__attribute__((dllimport))`)
614+
$(LI `__attribute__((naked))`)
615+
$(LI `__attribute__((noinline))`)
616+
$(LI $(RELATIVE_LINK2 noreturn, `__attribute__((noreturn))`))
617+
$(LI others are ignored)
618+
)
619+
603620
$(H3 $(LNAME2 noreturn, `__attribute__((noreturn))`))
604621

605622
$(P `__attribute__((noreturn))` marks a function as never returning.
@@ -628,16 +645,46 @@ $(H2 $(LNAME2 visualc-extensions, Visual C Extensions))
628645

629646
$(P All the $(RELATIVE_LINK2 digital-mars-extensions, Digital Mars C Extensions).)
630647

631-
$(H2 $(LNAME2 digital-mars-extensions, Digital Mars C Extensions))
632-
633648
$(H3 $(LNAME2 __stdcall, `__stdcall` Function Calling Convention))
634649

635-
$(P This sets the calling convention for a function to the Windows API calling convention.)
650+
$(P `__stdcall` sets the calling convention for a function to the Windows API calling convention.)
636651

637652
---
638653
int __stdcall foo(int x);
639654
---
640655

656+
$(H3 $(LNAME2 __declspec, `__declspec` Attribute Extensions))
657+
658+
$(P The following $(LINK2 https://learn.microsoft.com/en-us/cpp/cpp/declspec?view=msvc-170, `__declspec` extensions):)
659+
660+
$(OL
661+
$(LI `__declspec(align(N))`)
662+
$(LI `__declspec(deprecated)`)
663+
$(LI `__declspec(dllexport)`)
664+
$(LI `__declspec(dllimport)`)
665+
$(LI `__declspec(naked)`)
666+
$(LI `__declspec(noinline)`)
667+
$(LI `__declspec(noreturn)`)
668+
$(LI `__declspec(thread)`)
669+
$(LI others are ignored)
670+
)
671+
672+
$(H2 $(LNAME2 digital-mars-extensions, Digital Mars C Extensions))
673+
674+
$(H3 $(LNAME2 __stdcall, `__stdcall` Function Calling Convention))
675+
676+
$(H3 $(LNAME2 __declspec, `__declspec` Attribute Extensions))
677+
678+
$(P The following $(LINK2 https://digitalmars.com/ctg/ctgLanguageImplementation.html#declspec, `__declspec` extensions):)
679+
680+
$(OL
681+
$(LI `__declspec(dllexport)`)
682+
$(LI `__declspec(dllimport)`)
683+
$(LI `__declspec(naked)`)
684+
$(LI `__declspec(thread)`)
685+
)
686+
687+
641688
$(H2 $(LNAME2 d-side, ImportC from D's Point of View))
642689

643690
$(P There is no one-to-one mapping of C constructs to D constructs, although

0 commit comments

Comments
 (0)