How to force an array literal into a read-only data segment?

a11e99z black80 at bk.ru
Thu Sep 12 08:54:09 UTC 2019


On Thursday, 12 September 2019 at 07:04:19 UTC, Max Samukha wrote:
>
> How to achieve the same for an array literal? The closest I 
> could come:
>
> enum immutable(int[3]) _tmp = [1, 2, 3];
> __gshared a = _tmp.ptr;
>
> Is it possible to force the array into rodata?

https://p0nce.github.io/d-idioms/#Precomputed-tables-at-compile-time-through-CTFE

static immutable(int[3]) _tmp = [1, 2, 3];
?


More information about the Digitalmars-d-learn mailing list