Matthew/Marc,

I did as Matthew said. I just defined the checks to be 0, then
followed rebuilding gcc4 instructions in FAQ/current.html by
rebuilding the libstdc++ headers (rm -rf /usr/include/g++ etc...).

Then I recompiled several large C++ programs (compiled FLTK 1.1.10
fully), one of those compiles fail because of new problems pointed by
clang++, I am going to raise those issues upstream.

In the below diff,

1) Both _GLIBCXX_USE_C99_CHECK  and  _GLIBCXX_USE_C99_DYNAMIC need to
be 0 to suppress those errors from cstdio
2) Both _GLIBCXX_USE_C99_LONG_LONG_CHECK and
_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC is needed to be 0 to suppress those
errors from cstdlib and cwchar.

After this diff against the in-tree libstdc++, clang++ now works on
OpenBSD with these changes. Can somebody please consider this for
inclusion after unlock?

Thanks

# cvs diff -ui gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h
Index: gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h
===================================================================
RCS file: /cvs/src/gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h,v
retrieving revision 1.2
diff -u -i gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h
--- gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h     26 May
2010 11:23:06 -0000      1.2
+++ gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h     16 Feb
2011 18:39:45 -0000
@@ -35,10 +35,10 @@
 // file will come before all others.

 #define _GLIBCXX_USE_C99 1
-#define _GLIBCXX_USE_C99_CHECK 1
-#define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999))
-#define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1
-#define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC (_GLIBCXX_USE_C99_DYNAMIC
|| !defined __LONG_LONG_SUPPORTED)
+#define _GLIBCXX_USE_C99_CHECK 0
+#define _GLIBCXX_USE_C99_DYNAMIC 0
+#define _GLIBCXX_USE_C99_LONG_LONG_CHECK 0
+#define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 0
 #define _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_CHECK 1
 #define _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC defined _XOPEN_SOURCE
 typedef __builtin_va_list __gnuc_va_list;




>> Finding out why it doesn't work with g++ from src would be
>> the correct approach.
>
> Investigating further, it seems to boil down to _GLIBCXX_USE_C99_CHECK
> in /usr/include/g++/*/bits/os_defines.h.  Including <cstdio> from base
> effectively feeds the following to the compiler:
>
>    typedef unsigned long size_t;
>
>    extern "C" {
>    int snprintf(char *, size_t, const char *, ...)
>      __attribute__((__format__ (printf, 3, 4)))
>      __attribute__((__nonnull__ (3)))
>      __attribute__((__bounded__ (__string__,1,2)));
>    }
>
>    namespace std {
>      extern "C" int
>      (snprintf)(char * restrict, size_t, const char * restrict, ...);
>      using ::snprintf;
>    }
>
> g++ doesn't mind the conflicting definitions for snprintf (it doesn't
> seem to care about *any* conflicts actually; you could put "int
> snprintf(double x)" and it's still happy), but clang++ does.
>
> We don't define anything in os_defines.h in libstdc++ from ports, so
> the the second chunk of code above never gets included.
>
> Perhaps we can get rid of _GLIBCXX_USE_C99_CHECK (along with the other
> *_CHECK defines) since it's apparently useless even with g++ and just
> causes compile trouble with clang++?  Also, maybe useful to add
> _GLIBCXX_USE_C99 to ports libstdc++?  (I'll test these ideas out
> later.)
# cvs diff -ui gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h 
Index: gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h
===================================================================
RCS file: /cvs/src/gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h,v
retrieving revision 1.2
diff -u -i gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h
--- gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h     26 May 2010 11:23:06 -0000      1.2
+++ gnu/gcc/libstdc++-v3/config/os/bsd/openbsd/os_defines.h     16 Feb 2011 18:39:45 -0000
@@ -35,10 +35,10 @@
 // file will come before all others.
 
 #define _GLIBCXX_USE_C99 1
-#define _GLIBCXX_USE_C99_CHECK 1
-#define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999))
-#define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1
-#define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC (_GLIBCXX_USE_C99_DYNAMIC || !defined __LONG_LONG_SUPPORTED)
+#define _GLIBCXX_USE_C99_CHECK 0
+#define _GLIBCXX_USE_C99_DYNAMIC 0
+#define _GLIBCXX_USE_C99_LONG_LONG_CHECK 0
+#define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 0
 #define _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_CHECK 1
 #define _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC defined _XOPEN_SOURCE
 typedef __builtin_va_list __gnuc_va_list;

Reply via email to