in file main.c there is a code.
here is the code:
The initialization value must be a compile time constant. a is a
variable. Even if you defined a as const short, it is still not a
compile time constant.
解决方案
Your options for compile time constant initialization goes beyond hard-coded
values: You may initialize it to some macro's value (#define BOOOO_HISSSS)
or a specific enum value. The enum hackonly works for int.
With variables you can of course get around it by simply assigning after
declaring(instead of all-in-one initialization). The real problem rears it's
ugly head when you want to inizialize a const with somevalue based another
const.
Are there any other ways besides setting them to a macro or enum?
i.e.
------------------msdn上的样例和解释---------------------
C2099 can also occur because the compiler is not able to perform constant folding on an expression under /fp:strict because the floating point precision environment settings (see _controlfp_s for more information) may differ from compile to run time.
When constant folding fails, the compiler invokes dynamic initialization, which is not allowed in C.
To resolve this error, compile the module as a .cpp file or simplify the expression.
For more information, see /fp (Specify Floating-Point Behavior).
或者
This error is issued only by the C compiler and occurs only for non-automatic variables. The compiler initializes non-automatic variables at the start of the program and the values they are initialized with must be constant.
或者