In a testdir of getopt-posix, getopt-gnu, as well as in GNU gettext, I see these test failures on mingw:
FAIL: test-getopt-gnu ===================== ../../../gettext-tools/gnulib-tests/test-getopt.h:772: assertion 'strcmp (argv[1], "-p") == 0' failed FAIL test-getopt-gnu.exe (exit status: 3) FAIL: test-getopt-posix ======================= ../../../gettext-tools/gnulib-tests/test-getopt.h:772: assertion 'strcmp (argv[1], "-p") == 0' failed FAIL test-getopt-posix.exe (exit status: 3) There is no failure in OpenBSD, Cygwin, Android, which have the same configure-time findings as mingw, namely gl_cv_func_getopt_gnu=yes gl_cv_func_getopt_long_gnu=yes Also, there is no failure on mingw in a testdir that includes the 'argp' module, because in this case gl_REPLACE_GETOPT_ALWAYS is defined => REPLACE_GETOPT is set to 1 => __GETOPT_PREFIX gets defined in config.h. So, this patch fixes it. I don't remember why I had added this special casing of mingw in 2009. 2024-07-23 Bruno Haible <br...@clisp.org> getopt-posix, getopt-gnu tests: Avoid test failure on mingw. * tests/test-getopt.h (test_getopt): Don't special-case mingw. diff --git a/tests/test-getopt.h b/tests/test-getopt.h index f13b59596b..43d23ca1fa 100644 --- a/tests/test-getopt.h +++ b/tests/test-getopt.h @@ -85,8 +85,10 @@ test_getopt (void) bool posixly = !!getenv ("POSIXLY_CORRECT"); /* See comment in getopt.c: glibc gets a LSB-compliant getopt. - Standalone applications get a POSIX-compliant getopt. */ -#if defined __GETOPT_PREFIX || !(__GLIBC__ >= 2 || defined __MINGW32__) + Standalone applications get a POSIX-compliant getopt. + Note: The 'defined __GETOPT_PREFIX' condition is equivalent to + $REPLACE_GETOPT = 1 at configure time. */ +#if defined __GETOPT_PREFIX || !(__GLIBC__ >= 2) /* Using getopt from gnulib or from a non-glibc system. */ posixly = true; #endif