Conflict of 'new' keyword when including C header files into C++ modules

Ian Lance Taylor iant@google.com
Wed Jan 5 02:00:00 GMT 2011


Philip Prindeville <philipp_subx@redfish-solutions.com> writes:

> I was wondering why header files that are bracketed as:
>
> extern "C" {
> #include <linux/list.h>
> ...
> }
>
> still have a problem with this.  Do the C++ keywords still exist while in the "C" space?

Yes.  extern "C" only changes the external names used for functions and
global variables, such that they are compatible with the names generated
by a C compiler.  It does not change the actual language.  You can write
normal C++ code within an extern "C" block.

> What's the easiest work-around?

Fixing the code?

#define new avoid_cxx_new_keyword ?

Ian



More information about the Gcc-help mailing list