Hello all,
Another trivial question. Is this valid C code?
The program compiles and runs fine on my C++ compiler. Unfortunately I haven't got a C compiler to test it on, but I am assuming a C compiler will handle it the same way (or as that assumption wrong?).Code:#include <stdio.h> int a = 2, b = 2, c = a + b; void main(void) { printf("%d", c); return; }
According to everything I've read, static variables must be initialised with constant expressions. "c" above is a static variable; however, "a + b" is not what I would consider to be a constant expression, even if its value clearly is constant here. So I would have expected a compilation error. Why don't I get one?
Suggestions would be most appreciated, etc.