On Saturday, 11 June 2022 at 10:07:46 UTC, test123 wrote:
how to work this around.

```d
__gshared const TEST = import(`onlineapp.d`);
extern(C) void main(){
        __gshared  bin_ptr = TEST.ptr;
}
```

```sh
dmd2 -betterC -J. onlineapp.d
onlineapp.d(3): Error: cannot use non-constant CTFE pointer in an initializer `cast(immutable(char)*)TEST`

```

Maybe try putting `__gshared bin_ptr = TEST.ptr;` inside a `shared static this(){}`?

I mean, write it like:
```d
__gshared  bin_ptr;
shared static this()
{
    bin_ptr = TEST.ptr;
}

__gshared const TEST = import(`onlineapp.d`);


extern(C) void main()
{
}
```

But `bin_ptr` becomes a global in this case :(

Reply via email to