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: gcc-2.9[67]: C++: extern "C" functions with empty argument-lists refuse to accept arguments.


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
> ----------------------------------------------------------------------------
> */

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