Is it possible to call all shared static ctors in betterC?
//-betterC
static immutable int i;
shared static this(){
i = 42;
}
extern(C) void main(){
assert(i != 42);
}
Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 21, 2021 betterC shared static ctor | ||||
---|---|---|---|---|
| ||||
Is it possible to call all shared static ctors in betterC?
|
July 21, 2021 Re: betterC shared static ctor | ||||
---|---|---|---|---|
| ||||
Posted in reply to vit | On Wednesday, 21 July 2021 at 08:11:06 UTC, vit wrote: >Is it possible to call all shared static ctors in betterC?
These rely on DRuntime, which is not linked in betterC mode. You'll need to use the https://dlang.org/spec/pragma.html#crtctor Apply them to any `extern(C) function for static ctor/dtor behavior. |
July 21, 2021 Re: betterC shared static ctor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Wednesday, 21 July 2021 at 08:28:22 UTC, Mike Parker wrote: >On Wednesday, 21 July 2021 at 08:11:06 UTC, vit wrote: >Is it possible to call all shared static ctors in betterC?
These rely on DRuntime, which is not linked in betterC mode. You'll need to use the https://dlang.org/spec/pragma.html#crtctor Apply them to any `extern(C) function for static ctor/dtor behavior. Thanks, it works, but now I have different problem. I need this to work but for all instantions of Foo, not only for Foo!1 a Foo!2 https://run.dlang.io/is/FNqHWh :
|
July 21, 2021 Re: betterC shared static ctor | ||||
---|---|---|---|---|
| ||||
Posted in reply to vit | On 7/21/21 5:07 AM, vit wrote: >Thanks, it works, but now I have different problem. Not unless you register them somehow upon instantiation. Or (I think) you can implement the constructor as a static method, and tag it with -Steve |