In C it is an error
int x=5;
static int y=x; //error
In C++ it is valid why?
int x=5;
static int y=x; //valid
In C it is an error
int x=5;
static int y=x; //error
In C++ it is valid why?
int x=5;
static int y=x; //valid
Because C and C++ are different languages.
C++ has a dynamic initialisation stage when the program starts, in which static variables can be initialised using either non-trivial constructors or non-constant initialisers. C doesn't, and requires static variables to be initialised with constant expressions.