I am getting ERROR when I am running this program at the line
static int b = a; //error : initializer element is not constant
Can not understand why?
#include <stdio.h>
// #include <setjmp.h>
int main()
{
int a = 5;
static int b = a;
return 0;
}
Apart from the other reasons stated in other answers here, please see the below statement in the Standard.
The C Standard says this in Point-4 (Section 6.7.8 Initialization):
Additionally, as to what is a constant expression, it says in Section 6.6 Constant Expressions as below: