From: Keith Marshall Date: Mon, 5 Jun 2017 19:15:12 +0000 (+0100) Subject: Automatically correct obsolete _XOPEN_SOURCE usage. X-Git-Tag: wsl-5.0.1-release~5 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=16ab58171b55e2959b97866b6fc8e913615c8e03;p=mingw%2Fmingw-org-wsl.git Automatically correct obsolete _XOPEN_SOURCE usage. --- diff --git a/mingwrt/ChangeLog b/mingwrt/ChangeLog index 2765231..6b604b3 100644 --- a/mingwrt/ChangeLog +++ b/mingwrt/ChangeLog @@ -1,3 +1,12 @@ +2017-06-05 Keith Marshall + + Automatically correct obsolete _XOPEN_SOURCE usage. + + * include/_mingw.h.in (__paste, __valueless): New macros; define them. + (_XOPEN_SOURCE) [defined with no value]: Use them to attempt to deduce + this obsolete usage; if detected, redefine it with a default assigned + value of one, emulating -D_XOPEN_SOURCE command line definition. + 2017-05-24 Keith Marshall Fix snprintf()/vsnprintf() -Wformat vs. multiple definition issue. diff --git a/mingwrt/include/_mingw.h.in b/mingwrt/include/_mingw.h.in index 5e54a22..1cd2b57 100644 --- a/mingwrt/include/_mingw.h.in +++ b/mingwrt/include/_mingw.h.in @@ -401,6 +401,31 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */ # endif #endif +/* Some applications may define _XOPEN_SOURCE, without assigning any + * value to it. Such usage may have been permitted in early SUS, but + * it became obsolete as of SUSv2. Attempt to detect obsolete usage, + * as it makes an effective evaluation of any _XOPEN_SOURCE version + * dependency difficult, (without the use of ugly kludges at EVERY + * point of reference which attempts a version comparison). + */ +#define __paste(prefix,suffix) prefix ## suffix +#define __valueless(token) ((token - 0) == 0) && (__paste(token,10) == 10) + +#if defined _XOPEN_SOURCE && __valueless(_XOPEN_SOURCE) +/* _XOPEN_SOURCE appears to have been defined without its mandatory + * value; diagnose this brain-damaged obsolete usage (verbosely)... + */ +#warning "_XOPEN_SOURCE seems to have been improperly defined." +#warning "Mandatory _XOPEN_SOURCE value assignment appears to be missing." +#warning "Redefining _XOPEN_SOURCE to mitigate obsolete misuse." + +/* ...and redefine, emulating implicit behaviour of -D_XOPEN_SOURCE on + * the GCC command line, (which DOES assign an implied value of one). + */ +#undef _XOPEN_SOURCE +#define _XOPEN_SOURCE 1 +#endif + #ifndef _POSIX_C_SOURCE /* Users may define this, either directly or indirectly, to explicitly * enable a particular level of visibility for the subset of those POSIX