+2025-06-29 Bruno Haible <bruno@clisp.org>
+
+ options: Support use in a shared library on mingw.
+ * lib/options.h (_gl_get_next_option): New declaration.
+ (get_next_option): On mingw, define in terms of _gl_get_next_option.
+ * lib/options.c (_gl_get_next_option): On mingw, define this function
+ instead of get_next_option.
+
2025-06-29 Paul Eggert <eggert@cs.ucla.edu>
open, openat: port O_DIRECTORY changes to OS X
}
int
+#ifdef __MINGW32__
+_gl_get_next_option (int *optind_p, char **optarg_p, int *optopt_p)
+#else
get_next_option (void)
+#endif
{
if (state.argv == NULL)
{
*(options[i].variable) = options[i].value;
}
}
+#ifdef __MINGW32__
+ /* On mingw, when this file is compiled into a shared library, it pulls
+ mingw's getopt.o file (that defines getopt_long, opterr, optind, optarg,
+ optopt) into the same shared library. Since these variables are declared
+ and defined without any __declspec(dllexport) or __declspec(dllimport),
+ the effect is that there are two copies of the variables: one in the
+ shared library and one in the executable. Upon return from this function,
+ we need to copy the values of the output variables (optind, optarg, optopt)
+ from the shared library into the executable, where the main() function will
+ pick them up. */
+ *optind_p = optind;
+ *optarg_p = optarg;
+ *optopt_p = optopt;
+#endif
return ret;
}
specified) ':'.
If the processing is terminated, it returns -1. */
extern int get_next_option (void);
+#ifdef __MINGW32__
+extern int _gl_get_next_option (int *optind_p, char **optarg_p, int *optopt_p);
+# define get_next_option() _gl_get_next_option (&optind, &optarg, &optopt)
+#endif
#ifdef __cplusplus
}