This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: "ANSI C++ forbids declaration with no type" in extern "C"
- To: adisaacs at trurl dot resnet dot mtu dot edu
- Subject: Re: "ANSI C++ forbids declaration with no type" in extern "C"
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Mon, 6 Apr 1998 10:22:28 +0200
- CC: egcs-bugs at cygnus dot com
- References: <19980405121039.12335@mtu.edu>
> % cat foo.cc
> extern "C" {
> foo(void);
> };
> int bar(void) { return foo(); }
> % g++ foo.cc
> foo.cc:2: warning: ANSI C++ forbids declaration `' with no type
> foo.cc:2: abstract declarator `int' used as declaration
> foo.cc: In function `int bar()':
> foo.cc:4: warning: implicit declaration of function `int foo(...)'
>
> Shouldn't that work?
The first warning is correct; this code is not valid C++. Given that
g++ seems to do the right thing, the second warning should not be
issued. If you look at the generated assembler, you'll see that it
still calls the right function.
There seems to be a memory corruption somewhere, as the assembler
also contains 'funny' labels (on i486-pc-linux-gnu):
.size bar__Fv,.Lfe1-bar__Fv
.globl Pš"
.bss
.align 4
.type Pš",@object
.size Pš",4
Pš":
.zero 4
Regards,
Martin