RE: Is this a bug in gcc??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 Name lastlong wrote:
> Hi,
> 
> I am expecting a error (redefinition of "a") from following piece of 
> code. But gcc (3.4.2) doesnot give any error.
> /////////////////
> int a;
> char b;
> int a;

Just to expand on what has already been said.
gcc/g++ behave as required by the standard. But to make sure we compare
apples to apples.

If you add the above to the file: test.c

gcc -c test.c   # Works Fine     (as expected)
g++ -c test.c   # Outputs errors (as expected)

Note that gcc is a C compiler (or should I say invokes the underlying C
Compiler by default) while g++ is a C++ compiler. NB If you name the
file test.cpp the content is C++ and the C++ compiler will be invoked no
matter how 'Gcc' is invoked (unless you explicitly override the
defaults).




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux