Optimized (but not debug) builds fail to compile setlocale.cpp with the error:
$ cat t.cpp; CC -c t.cpp
"/opt/sunpro/12_3/prod/include/cc/wchar.h", line 90: Error: tm is not defined.
"/opt/sunpro/12_3/prod/include/cc/wchar.h", line 92: Error: fgetwc is not
and so on for every wide-char function in wchar.h.
The definition of _XOPEN_SOURCE at the top of setlocale.cpp is not entirely
correct in that it interacts with the various guards in the C library headers.
AFAICT, Oracle/Sun wchar.h includes C library wchar.h, which includes C library
wctype.h, which includes again wchar.h, coming full circle to the compiler
wchar.h which uses the names w/o them being defined, yet. The fact that
Oracle/Sun headers include_next corresponding C library headers outside of a
inclusion guard does not help.
(Debug builds are not affected because of interaction from the difference in the
structure and includes of rw/_traits.h in debug vs. optimized builds).
The poor man's fix is to guard that _XOPEN_SOURCE define for SUNPro builds (see
below). However, I am not sure whose side the error is.
PS. Is it still called SUNPro? Oracles seems it has sanitized that name out on
--- src/setlocale.cpp (revision 1388733)
+++ src/setlocale.cpp (working copy)
@@ -34,8 +34,10 @@
#if defined (__linux__) && !defined (_XOPEN_SOURCE)
+# if !defined (__SUNPRO_CC)
// need S_IFDIR on Linux
# define _XOPEN_SOURCE
+# endif // !__SUNPRO_CC
#endif // __linux__ && !_XOPEN_SOURCE
#include <locale.h> // for setlocale()