On Fri, Jun 15, 2012 at 11:27 AM, Duncan Sands <[email protected]> wrote:
> My plugin is written in C++. When including headers from gcc-4.6 it wraps
> them
> in 'extern "C"' to prevent name mangling. Some of the plugin headers
> include
> gcc/system.h which includes the C++ header cstring if it detects the use of
> a
> C++ compiler. As a result cstring routines included this way end up wrapped
> in
> 'extern C', while those included directly from C++ aren't 'extern C'. This
> doesn't worry g++, but clang gets upset, erroring out with a complaint about
> multiple inconsistent declarations of memchr and friends. Is the following
> patch OK to apply to gcc-4.6? And is it in principle OK to apply to gcc-4.7
> (I didn't test it there yet)? It would be useful if gcc-4.7 is compiled as
> C.
Uh, I don't think we should do that. Why do we include cstring here anyways?
Ian - you added this include in rev. 167764, I don't think that was "proper".
But I'm not sure wrapping a system.h include inside extern "C" from a C++
plugin is proper either ...
Thanks,
Richard.
> Thanks, Duncan.
>
> Index: gcc/system.h
> ===================================================================
> --- gcc/system.h (revision 188518)
> +++ gcc/system.h (working copy)
> @@ -191,7 +191,9 @@
> #endif
>
> #ifdef __cplusplus
> +extern "C++" {
> # include <cstring>
> +}
> #endif
>
> /* Some of glibc's string inlines cause warnings. Plus we'd rather