Compilation Error :Reasoning:

shwetank's Avatar, Join Date: Oct 2010
Newbie Member
Code:
------

int x,x;
int main(){
int x,x;
x = 10;
return 0;
}

In this code ... if i commented out the local declaration of "int x,x;" (inside main) the code compiling successfuly..
But if commented out global ones and not local one's we will get compilation error for the same variables name declaration...
Can sb let me know the resoning behind the same.
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Probably a compiler bug. The error message is correct and you should get it for both faulty declarations. What compiler are you using?
0
shwetank's Avatar, Join Date: Oct 2010
Newbie Member
Quote:
Originally Posted by xpi0t0s View Post
Probably a compiler bug. The error message is correct and you should get it for both faulty declarations. What compiler are you using?
I tried it on GCC and CC on linux(suse)
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
What version?
0
shwetank's Avatar, Join Date: Oct 2010
Newbie Member
Quote:
Originally Posted by xpi0t0s View Post
What version?
Its a default one...
Have u tried the same code in ur C compiler
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Quote:
Originally Posted by shwetank View Post
Its a default one...
That completely doesn't answer the question.

Quote:
Have u tried the same code in ur C compiler
Why would I need to? It's invalid code. Anyway, since you can't be arsed to find out how to make gcc print its version, I can't be arsed either.