tell if __traits(allMembers, ... ) is an enum (not manifest constant)
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Feb 25 03:13:12 PST 2016
On Thursday, 25 February 2016 at 08:40:00 UTC, nkgu wrote:
> On Thursday, 25 February 2016 at 04:55:09 UTC, Nicholas Wilson
> wrote:
>>
>> oops should be
>> writeln(typeof(__traits(getMember, vulkan_input,
>> m)).stringof);
>> that compiles but still prints nothing
>
> try
>
> pragma(msg, typeof(__traits(getMember, vulkan_input,
> m)).stringof);
>
> because at compile time the code generated for writeln() is not
> executed.
>
> Also take care with the getMember trait, it will only work if
> the member is public.
> (or not public but located in the module where the __traits()
> code resides).
Heh. Thanks for the Idea anyway.
source/app.d(308): Error: module object has no type
source/app.d(308): while evaluating pragma(msg,
(_error_).stringof)
source/app.d(308): Error: type uint is not an expression
source/app.d(308): while evaluating pragma(msg,
(_error_).stringof)
pure nothrow @nogc @safe int(int major, int minor, int patch)
int
int
pure nothrow @nogc @safe uint(uint ver)
pure nothrow @nogc @safe uint(uint ver)
pure nothrow @nogc @safe uint(uint ver)
...
void
void
...
source/app.d(308): Error: type VkInstance_T is not an expression
source/app.d(308): while evaluating pragma(msg,
(_error_).stringof)
...
Cheating somewhat
static if(m.startsWith("Vk") && __traits(compiles,
mixin(m~"."~m.camelToUpper_ ~ "_MAX_ENUM")))
does some of what I want but (unsurprisingly) fails to pick up
the bitfield enums (that don't have a "_MAX_ENUM" member).
More information about the Digitalmars-d-learn
mailing list