need help to check symbol is static variable or not

Dakota dakota at gmail.com
Mon Jul 1 07:32:30 UTC 2024


this code give error:

```d
static if(  !__traits(compiles, mixin("enum v = V;")) ) {
    enum v = V;
}

```

```sh
  Error: static variable `NotWorkVar` cannot be read at compile 
time
```

V is alias get from `typeof(__traits(getMember, M, symbol)`,  M 
is `module` from importC.


the importC source "test.h" code for `NotWorkVar`

```c
extern const float NotWorkVar;
```

I am try to ` static foreach(symbol; __traits(allMembers, 
importCModule))`,  and want to check if the symbol is `static 
variable` or not at compile time.




More information about the Digitalmars-d-learn mailing list