Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Compilation Error :Reasoning: (http://www.go4expert.com/forums/compilation-error-reasoning-t23515/)

shwetank 7Oct2010 17:27

Compilation Error :Reasoning:
 
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.

xpi0t0s 8Oct2010 12:47

Re: Compilation Error :Reasoning:
 
Probably a compiler bug. The error message is correct and you should get it for both faulty declarations. What compiler are you using?

shwetank 8Oct2010 13:03

Re: Compilation Error :Reasoning:
 
Quote:

Originally Posted by xpi0t0s (Post 73518)
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):embarasse

xpi0t0s 8Oct2010 13:31

Re: Compilation Error :Reasoning:
 
What version?

shwetank 8Oct2010 16:19

Re: Compilation Error :Reasoning:
 
Quote:

Originally Posted by xpi0t0s (Post 73521)
What version?

Its a default one...
Have u tried the same code in ur C compiler

xpi0t0s 8Oct2010 20:21

Re: Compilation Error :Reasoning:
 
Quote:

Originally Posted by shwetank (Post 73533)
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.


All times are GMT +5.5. The time now is 23:11.