This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: "ANSI C++ forbids declaration with no type" in extern "C"


> % 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]