Eric Blake wrote: > this would be > better written as a compile-time test that sees whether mbstate_t is > visible first without, then with -D_XOPEN_SOURCE=500 added to CFLAGS, in > case HP (or gcc fixincludes) fixes the problem, or in case someone else > has a similar issue.
This has the potential of breaking unrelated platforms, in theory. But your suggestion has good chances of working fine: The only other platform which defines mbstate_t depending on some compiler flags is AIX. On AIX 4 and 5, mbstate_t is defined if _XOPEN_SOURCE == 500. But _XOPEN_SOURCE == 500 is already implied by -D_ALL_SOURCE and is also implicit if none of _XOPEN_SOURCE, _POSIX_SOURCE, _ANSI_C_SOURCE is defined. Therefore this test, applied to AIX, will be a no-op in most cases and a fix (like for HP-UX) in the rare case that the user has already specified _POSIX_SOURCE or _ANSI_C_SOURCE. Note that the proposed test should be run *after* -D_ALL_SOURCE has been added to the compiler flags. If you write a patch for this, I can test it for you (on HP-UX, AIX, and others). Bruno