Why isn't this expression const?

Brian Palmer d at brian.codekitchen.net
Wed May 9 12:12:23 PDT 2007


This code won't compile:

 struct Vector3 { float x,y,z; }
 const Vector3 ROT_FORCE_CCW = {0, 400_000, 0};
 const Vector3 ROT_FORCE_CW  = {0, ROT_FORCE_CCW.y*-1, 0};

That last line gives me the error:

 Error: non-constant expression *((& ROT_FORCE_CCW+4)) * -1.0e+0F

Strangely, I can do the equivalent three lines with basic types like ints just fine, but I can't get this struct initialization to work. Am I doing something wrong, or is it just lack of compiler smarts? I'm using (gdc 0.23, using dmd 1.007)


More information about the Digitalmars-d-learn mailing list