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
