So I get the 'initializer element not constant' error when compiling the following code:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
float wl = 2.0f;
float k = 2.0f * (float) M_PI / wl;
int main ()
{
//Do stuff
}
If I move "float k"
inside the main method, there's no errors, but this isn't an option for me, because I NEED float k to be a global variable. Even if I change it to this:
const float wl = 2.0f;
const float k = 2.0f * (float) M_PI / wl;
the error still happens. How do I fix this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…