stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Liviu Nicoara <nikko...@hates.ms>
Subject SUNPro 5.12 compilation failure in optimized Linux builds
Date Sat, 22 Sep 2012 04:51:20 GMT
Optimized (but not debug) builds fail to compile setlocale.cpp with the error:

$ cat t.cpp; CC -c t.cpp
#define _XOPEN_SOURCE
#include <cwchar>
"/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 defined.
...

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.

Thanks,
Liviu

PS. Is it still called SUNPro? Oracles seems it has sanitized that name out on 
their website.

Index: src/setlocale.cpp
===================================================================
--- src/setlocale.cpp	(revision 1388733)
+++ src/setlocale.cpp	(working copy)
@@ -34,8 +34,10 @@
  #include <rw/_defs.h>

  #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()

Mime
View raw message