Compilation Error :Reasoning:

Newbie Member
7Oct2010,17:27   #1
shwetank's Avatar
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.
Mentor
8Oct2010,12:47   #2
xpi0t0s's Avatar
Probably a compiler bug. The error message is correct and you should get it for both faulty declarations. What compiler are you using?
Newbie Member
8Oct2010,13:03   #3
shwetank's Avatar
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)
Mentor
8Oct2010,13:31   #4
xpi0t0s's Avatar
What version?
Newbie Member
8Oct2010,16:19   #5
shwetank's Avatar
Quote:
Originally Posted by xpi0t0s View Post
What version?
Its a default one...
Have u tried the same code in ur C compiler
Mentor
8Oct2010,20:21   #6
xpi0t0s's Avatar
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.