Can not get struct member addresses at compile time
jfondren
julian.fondren at gmail.com
Wed Jun 16 13:26:43 UTC 2021
On Wednesday, 16 June 2021 at 11:56:31 UTC, Mike Parker wrote:
> https://dlang.org/spec/pragma.html#crtctor
"as a simple replacement for shared static this in betterC mode"
Cool.
However,
```d
immutable int example;
version(D_BetterC) {
pragma(crt_constructor) extern(C) void initialize() {
example = 1;
}
} else {
shared static this() {
example = 1;
}
}
```
this compiles without -betterC; with -betterC it errors out:
Error: cannot modify `immutable` expression `example`
Is this a bug?
More information about the Digitalmars-d-learn
mailing list