Description of problem: On Fedora 8 this program fails to compile using the Sun Studio Express C++ compiler for GNU/Linux: #include <stdio.h> #include <iostream> int main() { } See this forum topic for more information: http://forum.java.sun.com/thread.jspa?messageID=10036641#10036641 Version-Release number of selected component (if applicable): glibc-2.7-2.x86_64 glibc-2.7-2.i686 How reproducible: Always Steps to Reproduce: Compile the example code above with sunCC on Fedora8 Actual results: $ sunCC -V sunCC: Sun Ceres C++ 5.9 Linux_i386 2008/01/28 $ sunCC bug.cc "/opt/sun/sunstudioceres/prod/include/CC/Cstd/iosfwd", line 74: Error: mbstate_t is not defined. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/iosfwd", line 75: Error: mbstate_t is not defined. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/traits", line 191: Error: "," expected instead of "state_type". "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/traits", line 194: Error: Use ";" to terminate declarations. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/traits", line 261: Error: "," expected instead of "get_state". "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/traits", line 265: Error: Use ";" to terminate declarations. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/traits", line 299: Error: "," expected instead of "state_type". "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/traits", line 302: Error: Use ";" to terminate declarations. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/traits", line 410: Error: "," expected instead of "get_state". "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/traits", line 414: Error: Use ";" to terminate declarations. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/rwlocale", line 125: Error: mbstate_t is not defined. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/rwlocale", line 125: Error: Template parameter std::stateT requires a type argument. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/rwlocale", line 130: Error: mbstate_t is not defined. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/rwlocale", line 130: Error: Template parameter std::stateT requires a type argument. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/codecvt", line 55: Error: mbstate_t is not defined. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/codecvt", line 55: Error: Template parameter std::stateT requires a type argument. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/codecvt", line 61: Error: "," expected instead of "state_type". "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/codecvt", line 63: Error: Use ";" to terminate declarations. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/codecvt", line 138: Error: mbstate_t is not defined. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/codecvt", line 138: Error: Template parameter std::stateT requires a type argument. "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/codecvt", line 144: Error: "," expected instead of "state_type". "/opt/sun/sunstudioceres/prod/include/CC/Cstd/rw/codecvt", line 146: Error: Use ";" to terminate declarations. 22 Error(s) detected. Expected results: The program should compile. Additional info: As I explained in the forum topic referenced above, the cause is that glibc's wchar.h defines __need_wint_t assuming it will be undefined by stddef.h - but if the compiler is not GCC then it stays defined and when <wchar.h> is included again, _WCHAR_H never gets set. wchar.h already accommodates compilers that don't define wint_t in <stddef.h> by defining it: # undef __need_wint_t # define __need_wint_t # include <stddef.h> /* We try to get wint_t from <stddef.h>, but not all GCC versions define it there. So define it ourselves if it remains undefined. */ # ifndef _WINT_T /* Integral type unchanged by default argument promotions that can hold any value corresponding to members of the extended character set, as well as at least one value that does not correspond to any member of the extended character set. */ # define _WINT_T typedef unsigned int wint_t; It seems to me that __need_wint_t should get #undef'd in that case, since it's no longer needed.
That's bug on the Sun studio stddef.h side. The (numerous __need_*) macros are part of the Linux APIs, so if their stddef.h doesn't use them and undef them, it has been ported incorrectly.