Scope hiding in C
问题 Does C have scope hiding? For example, if I have a global variable: int x = 3; can I 'declare' inside a function or main 'another' int x? 回答1: Yes, that's how C works. For example: int x; void my_function(int x){ // this is another x, not the same one } void my_function2(){ int x; //this is also another x { int x; // this is yet another x } } int main(){ char x[5]; // another x, with a different type } 回答2: Yes but some compilers complain or can be told to complain. For gcc , use -Wshadow .