Skip to content

Commit db60ee3

Browse files
authored
Merge pull request #1659 from WalterBright/getLinkage
Issue 17419 - add __traits(getLinkage, s) to the the linkage of symbol s
2 parents 14954e3 + 7b1e803 commit db60ee3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

spec/traits.dd

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ $(GNAME TraitsKeyword):
4343
$(GBLINK getAttributes)
4444
$(GBLINK getFunctionAttributes)
4545
$(GBLINK getFunctionVariadicStyle)
46+
$(GBLINK getLinkage)
4647
$(GBLINK getMember)
4748
$(GBLINK getOverloads)
4849
$(GBLINK getParameterStorageClasses)
@@ -532,6 +533,33 @@ pragma(msg, __traits(getFunctionAttributes, (int x) @trusted { return x * 2; }))
532533
---
533534
)
534535

536+
$(H2 $(GNAME getLinkage))
537+
538+
$(P Takes one argument, which is a declaration symbol, or the type of a function,
539+
delegate, or pointer to function.
540+
Returns a string representing the $(LINK2 attribute.html#LinkageAttribute, LinkageAttribute)
541+
of the declaration.
542+
The string is one of:
543+
)
544+
545+
$(UL
546+
$(LI $(D "D"))
547+
$(LI $(D "C"))
548+
$(LI $(D "C++"))
549+
$(LI $(D "Windows"))
550+
$(LI $(D "Pascal"))
551+
$(LI $(D "Objective-C"))
552+
$(LI $(D "System"))
553+
)
554+
555+
---
556+
extern (C) int fooc();
557+
alias aliasc = fooc;
558+
559+
static assert(__traits(getLinkage, fooc) == "C");
560+
static assert(__traits(getLinkage, aliasc) == "C");
561+
---
562+
535563
$(H2 $(GNAME getMember))
536564

537565
$(P Takes two arguments, the second must be a string.

0 commit comments

Comments
 (0)