Message ID | yddd3h3lrk3.fsf@manam.CeBiTec.Uni-Bielefeld.DE |
---|---|
State | New |
Headers | show |
On Thu, 21 Jul 2011, Rainer Orth wrote: > diff --git a/gcc/system.h b/gcc/system.h > --- a/gcc/system.h > +++ b/gcc/system.h > @@ -24,6 +24,10 @@ along with GCC; see the file COPYING3. > #ifndef GCC_SYSTEM_H > #define GCC_SYSTEM_H > > +#ifdef __cplusplus > +extern "C" { > +#endif > + I don't think it's right to surround any system header includes with extern "C". If a particular declaration in system.h needs to be extern "C", surround only that declaration (though preferably such declarations might go in other headers with their own extern "C").
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes: > diff --git a/gcc/system.h b/gcc/system.h > --- a/gcc/system.h > +++ b/gcc/system.h > @@ -24,6 +24,10 @@ along with GCC; see the file COPYING3. > #ifndef GCC_SYSTEM_H > #define GCC_SYSTEM_H > > +#ifdef __cplusplus > +extern "C" { > +#endif > + > /* We must include stdarg.h before stdio.h. */ > #include <stdarg.h> > > @@ -969,4 +973,8 @@ helper_const_non_const_cast (const char > #define DEBUG_VARIABLE > #endif > > +#ifdef __cplusplus > +} > +#endif > + > #endif /* ! GCC_SYSTEM_H */ I agree with Joseph that this is wrong. We must never wrap the #include of a system header file with extern "C". That will simply break on some systems. You should only wrap extern "C" around the various HAVE_DECL declarations. > diff --git a/include/xregex2.h b/include/xregex2.h > --- a/include/xregex2.h > +++ b/include/xregex2.h > @@ -399,7 +399,11 @@ struct re_pattern_buffer > typedef struct re_pattern_buffer regex_t; > > /* Type for byte offsets within the string. POSIX mandates this. */ > +#if defined(__osf__) && defined(__cplusplus) > +typedef off_t regoff_t; > +#else > typedef int regoff_t; > +#endif No, the right way to handle this is to add regoff_t to include/xregex.h. Ian
diff --git a/gcc/system.h b/gcc/system.h --- a/gcc/system.h +++ b/gcc/system.h @@ -24,6 +24,10 @@ along with GCC; see the file COPYING3. #ifndef GCC_SYSTEM_H #define GCC_SYSTEM_H +#ifdef __cplusplus +extern "C" { +#endif + /* We must include stdarg.h before stdio.h. */ #include <stdarg.h> @@ -969,4 +973,8 @@ helper_const_non_const_cast (const char #define DEBUG_VARIABLE #endif +#ifdef __cplusplus +} +#endif + #endif /* ! GCC_SYSTEM_H */ diff --git a/include/xregex2.h b/include/xregex2.h --- a/include/xregex2.h +++ b/include/xregex2.h @@ -399,7 +399,11 @@ struct re_pattern_buffer typedef struct re_pattern_buffer regex_t; /* Type for byte offsets within the string. POSIX mandates this. */ +#if defined(__osf__) && defined(__cplusplus) +typedef off_t regoff_t; +#else typedef int regoff_t; +#endif /* This is the structure we store register match data in. See