mingw-w64's winstorecompat provides just dummy getenv() implementation which always returns NULL. So it is not very usable for winstorecompat UWP builds.
But mingw-w64's winstorecompat provides getenv_s() which returns the real environment variable content. So replace getenv() call by the getenv_s() which makes getopt() to work in both normal and UWP builds. --- mingw-w64-crt/misc/getopt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mingw-w64-crt/misc/getopt.c b/mingw-w64-crt/misc/getopt.c index 01b269d0a4d9..5fb7868429ad 100644 --- a/mingw-w64-crt/misc/getopt.c +++ b/mingw-w64-crt/misc/getopt.c @@ -319,6 +319,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options, { char *oli; /* option letter list index */ int optchar, short_too; + size_t var_size; static int posixly_correct = -1; if (options == NULL) @@ -339,7 +340,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options, * optreset != 0 for GNU compatibility. */ if (posixly_correct == -1 || optreset != 0) - posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); + posixly_correct = (getenv_s(&var_size, NULL, 0, "POSIXLY_CORRECT") == 0 && var_size > 0); if (*options == '-') flags |= FLAG_ALLARGS; else if (posixly_correct || *options == '+') -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public