Export (0) Print
Expand All
Expand Minimize
0 out of 7 rated this helpful - Rate this topic

Compiler Error C2099

Error Message

initializer is not a constant

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.

Example

The following sample generates C2099.

// C2099.c
int j;
int *p;
j = *p;   // C2099 *p is not a constant

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).

The following sample generates C2099.

// C2099_2.c
// compile with: /fp:strict /c
float X = 2.0 - 1.0;   // C2099
float X2 = 1.0;   // OK
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.