Thread overview
predefined version for "nogc" option
Sep 02
a11e99z
Sep 03
Kagamin
Sep 03
a11e99z
Sep 05
Kagamin
Sep 05
a11e99z
September 02
I need function that do one thing if GC enabled and other when disabled.

I filled issue about it, but maybe u can show some trick:
how to determine in code that "nogc" is enabled?

=======================================================
LDC supports command option:
-nogc = Do not allow code that generates implicit garbage collector calls.

but I cannot find corresponding predefined version in https://dlang.org/spec/version.html#predefined-versions

need to add version LDC_nogc or D_nogc.
the one should be enabled for -betterC too.

September 03
__traits(compiles,new int)
September 03
On Tuesday, 3 September 2019 at 08:18:13 UTC, Kagamin wrote:
> __traits(compiles,new int)

it doesn't work
https://run.dlang.io/is/zdD2cU

2 version of runtime exists:
- at compiletime when compiler/ctfe can use all features.
- and app runtime when constraints can exist such as no GC, no exceptions..

what exactly __traits(compiles) checks "can this code compile without any conditions?" ?
maybe need another trait "rtcompiles" to take into account current options/conditions?
September 05
At least

void f() @nogc
{
    static assert(__traits(compiles,new int));
}

fails
September 05
On Thursday, 5 September 2019 at 08:02:15 UTC, Kagamin wrote:
> At least
> void f() @nogc
> {
>     static assert(__traits(compiles,new int));
> }
> fails

u know that u haven't gc in blocks @nogc.

try to run
> static assert( __traits( compiles, new int));
> extern(C) int main() { return 0; }
for DMD/LDC:-betterC or LDC:-nogc

__traits( compiles, new int) is true.
but shouldn't cuz when u use "new int" in code u will get error - module compiled for noGC.
(probably we have issue here with __traits)
and I don't need error, I am trying to find workaround, so I need some flag/version to choose right code for version with GC and another.