Why won't gcc compile uninitialized global const?
问题 When I try to compile the following with g++: const int zero; int main() { return 0; } I get an error about an uninitialized const 'zero' . I thought that global variables were default initialized to 0 [1] ? Why isn't this the case here? VS compiles this fine. [1] For example, see https://stackoverflow.com/a/10927293/331785 回答1: My gcc is slightly more verbose: $ g++ zeroconst.c zeroconst.c:1:11: error: uninitialized const ‘zero’ [-fpermissive] We see that -fpermissive option will allow this