Warning for incompatible functions declared 'extern "C"'?
Nick
nospam@codesniffer.com
Fri Jul 25 04:47:00 GMT 2014
On Thu, 2014-07-24 at 09:19 +0100, Jonathan Wakely wrote:
> That is valid C++ code. C linkage doesn't mean the function has to
> actually be usable from C.
>
> You can also declare functions with C linkage that take reference
> parameters or throw exceptions.
I didn't know that. Out of curiosity...I assumed that one of the
ramifications of declaring some code w/ C linkage was that it emitted
symbols that have C mangling. Is that true? If so, how are C++ antics
handled in this scenario?
> > My question is: does GCC have a warning for this scenario?
> > Specifically, can it warn when something is declared extern "C" that's
> > incompatible with C linkage?
>
> No, there is no such warning as far as I know.
>
> Such a warning doesn't seem unreasonable, since *usually* (not not
> always) you want functions with C language linkage to be callable from
> C.
Ok well let me know if I should open an enhancement request ticket for
this.
More information about the Gcc-help
mailing list