Skip to content

Commit

Permalink
Merge pull request #1659 from WalterBright/getLinkage
Browse files Browse the repository at this point in the history
Issue 17419 - add __traits(getLinkage, s) to the the linkage of symbol s
  • Loading branch information
wilzbach committed Jun 7, 2017
2 parents 14954e3 + 7b1e803 commit db60ee3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/traits.dd
Expand Up @@ -43,6 +43,7 @@ $(GNAME TraitsKeyword):
$(GBLINK getAttributes)
$(GBLINK getFunctionAttributes)
$(GBLINK getFunctionVariadicStyle)
$(GBLINK getLinkage)
$(GBLINK getMember)
$(GBLINK getOverloads)
$(GBLINK getParameterStorageClasses)
Expand Down Expand Up @@ -532,6 +533,33 @@ pragma(msg, __traits(getFunctionAttributes, (int x) @trusted { return x * 2; }))
---
)

$(H2 $(GNAME getLinkage))

$(P Takes one argument, which is a declaration symbol, or the type of a function,
delegate, or pointer to function.
Returns a string representing the $(LINK2 attribute.html#LinkageAttribute, LinkageAttribute)
of the declaration.
The string is one of:
)

$(UL
$(LI $(D "D"))
$(LI $(D "C"))
$(LI $(D "C++"))
$(LI $(D "Windows"))
$(LI $(D "Pascal"))
$(LI $(D "Objective-C"))
$(LI $(D "System"))
)

---
extern (C) int fooc();
alias aliasc = fooc;

static assert(__traits(getLinkage, fooc) == "C");
static assert(__traits(getLinkage, aliasc) == "C");
---

$(H2 $(GNAME getMember))

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

0 comments on commit db60ee3

Please sign in to comment.