This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc-2.9[67]: C++: extern "C" functions with empty argument-lists refuse to accept arguments.
- To: fuchsia dot groan at virgin dot net
- Subject: Re: gcc-2.9[67]: C++: extern "C" functions with empty argument-lists refuse to accept arguments.
- From: Martin Sebor <sebor at roguewave dot com>
- Date: Fri, 17 Nov 2000 18:04:22 -0700
- CC: gcc-bugs at gcc dot gnu dot org
- Organization: Rogue Wave Software, Inc.
- References: <200011172031.UAA01194@sourdust.groan>
peter miller wrote:
>
> /*
> gcc version 2.97 20001115 (experimental)
>
> (via http://www.codesourcery.com/gcc-compile.shtml)
>
> fails to compile the following legal (AFAIK) C++
>
> */
>
> extern "C" {
> void func(); // <- g++ seems to think this is 'void func(void);'
Which it is. Linkage specification is part of a function type; extern
"C" doesn't change the strong typing of C++ to K&R style.
Regards
Martin
PS The semicolon after the closing brace of the extern "C"
declaration-seq is illedgal and will be rejected by a strict compiler.
> };
>
> int main() {
> func(0);
> }
>
> /*
> complaining:
>
> /tmp/@5444.7.cc: In function int main()':
> /tmp/@5444.7.cc:2: too many arguments to function void func()'
>
>
> Which means you can't include tcpd.h from C++.
>
> This was brought to my attention through gcc-2.96 in RedHat 7.0 (I have
> moaned at RedHat ;) and I just want to make sure you are aware of it so it
> doens't live into gcc 3.0
>
> --
> p e t e r m i l l e r * f u c h s i a . g r o a n @ v i r g i n . n e t
> ----------------------------------------------------------------------------
> */