Using mixin in array declarations

Marduk via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 19 01:46:08 PST 2016


In C one can do the following:

# define N 10

double M[N][N];


In D I would like to achieve the same result. I tried with:

mixin("int N = 10;");

double[N][N] M;


but the compiler (DMD) complained with Error: variable N cannot 
be read at compile time.

What am I doing wrong?


More information about the Digitalmars-d-learn mailing list