diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/hostname.c gettext-tools/src/hostname.c --- gettext-tools/src/hostname.c 2005-05-20 16:40:02.000000000 -0400 +++ gettext-tools/src/hostname.c 2005-11-11 11:02:07.203125000 -0500 @@ -99,7 +99,7 @@ static enum { default_format, short_format, long_format, ip_format } format; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "fqdn", no_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgattrib.c gettext-tools/src/msgattrib.c --- gettext-tools/src/msgattrib.c 2005-05-20 16:40:15.000000000 -0400 +++ gettext-tools/src/msgattrib.c 2005-11-11 11:01:39.484375000 -0500 @@ -69,7 +69,7 @@ static int to_change; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "add-location", no_argument, &line_comment, 1 }, { "clear-fuzzy", no_argument, NULL, CHAR_MAX + 8 }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgcat.c gettext-tools/src/msgcat.c --- gettext-tools/src/msgcat.c 2005-05-20 16:40:19.000000000 -0400 +++ gettext-tools/src/msgcat.c 2005-11-11 11:02:33.109375000 -0500 @@ -53,7 +53,7 @@ static const char *to_code; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "add-location", no_argument, &line_comment, 1 }, { "directory", required_argument, NULL, 'D' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgcmp.c gettext-tools/src/msgcmp.c --- gettext-tools/src/msgcmp.c 2005-05-20 16:40:23.000000000 -0400 +++ gettext-tools/src/msgcmp.c 2005-11-11 11:02:51.906250000 -0500 @@ -49,7 +49,7 @@ static bool multi_domain_mode = false; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "directory", required_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgcomm.c gettext-tools/src/msgcomm.c --- gettext-tools/src/msgcomm.c 2005-05-20 16:40:27.000000000 -0400 +++ gettext-tools/src/msgcomm.c 2005-11-11 11:03:09.406250000 -0500 @@ -55,7 +55,7 @@ static const char *to_code; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "add-location", no_argument, &line_comment, 1 }, { "directory", required_argument, NULL, 'D' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgconv.c gettext-tools/src/msgconv.c --- gettext-tools/src/msgconv.c 2005-05-20 16:40:31.000000000 -0400 +++ gettext-tools/src/msgconv.c 2005-11-11 11:03:21.671875000 -0500 @@ -52,7 +52,7 @@ static const char *to_code; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "add-location", no_argument, &line_comment, 1 }, { "directory", required_argument, NULL, 'D' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgen.c gettext-tools/src/msgen.c --- gettext-tools/src/msgen.c 2005-05-20 16:40:35.000000000 -0400 +++ gettext-tools/src/msgen.c 2005-11-11 11:03:54.531250000 -0500 @@ -48,7 +48,7 @@ static int force_po; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "add-location", no_argument, &line_comment, 1 }, { "directory", required_argument, NULL, 'D' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgexec.c gettext-tools/src/msgexec.c --- gettext-tools/src/msgexec.c 2005-05-20 16:40:40.000000000 -0400 +++ gettext-tools/src/msgexec.c 2005-11-11 11:04:07.546875000 -0500 @@ -74,7 +74,7 @@ static int exitcode; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "directory", required_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgfilter.c gettext-tools/src/msgfilter.c --- gettext-tools/src/msgfilter.c 2005-05-20 16:40:44.000000000 -0400 +++ gettext-tools/src/msgfilter.c 2005-11-11 11:04:19.062500000 -0500 @@ -97,7 +97,7 @@ static int sub_argc; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "add-location", no_argument, &line_comment, 1 }, { "directory", required_argument, NULL, 'D' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgfmt.c gettext-tools/src/msgfmt.c --- gettext-tools/src/msgfmt.c 2005-11-11 00:58:30.000000000 -0500 +++ gettext-tools/src/msgfmt.c 2005-11-11 11:04:30.546875000 -0500 @@ -163,7 +163,7 @@ static int do_statistics; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "alignment", required_argument, NULL, 'a' }, { "check", no_argument, NULL, 'c' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msggrep.c gettext-tools/src/msggrep.c --- gettext-tools/src/msggrep.c 2005-05-20 16:41:05.000000000 -0400 +++ gettext-tools/src/msggrep.c 2005-11-11 11:03:39.796875000 -0500 @@ -81,7 +81,7 @@ static struct grep_task grep_task[3]; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "add-location", no_argument, &line_comment, 1 }, { "comment", no_argument, NULL, 'C' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msginit.c gettext-tools/src/msginit.c --- gettext-tools/src/msginit.c 2005-11-11 00:59:01.000000000 -0500 +++ gettext-tools/src/msginit.c 2005-11-11 11:04:42.078125000 -0500 @@ -125,7 +125,7 @@ static bool no_translator; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "input", required_argument, NULL, 'i' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgmerge.c gettext-tools/src/msgmerge.c --- gettext-tools/src/msgmerge.c 2005-05-20 16:42:09.000000000 -0400 +++ gettext-tools/src/msgmerge.c 2005-11-11 11:04:51.328125000 -0500 @@ -84,7 +84,7 @@ static const char *backup_suffix_string; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "add-location", no_argument, &line_comment, 1 }, { "backup", required_argument, NULL, CHAR_MAX + 1 }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msgunfmt.c gettext-tools/src/msgunfmt.c --- gettext-tools/src/msgunfmt.c 2005-05-20 16:42:11.000000000 -0400 +++ gettext-tools/src/msgunfmt.c 2005-11-11 11:05:45.718750000 -0500 @@ -73,7 +73,7 @@ static int force_po; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "csharp", no_argument, NULL, CHAR_MAX + 4 }, { "csharp-resources", no_argument, NULL, CHAR_MAX + 5 }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/msguniq.c gettext-tools/src/msguniq.c --- gettext-tools/src/msguniq.c 2005-05-20 16:42:23.000000000 -0400 +++ gettext-tools/src/msguniq.c 2005-11-11 11:05:57.968750000 -0500 @@ -52,7 +52,7 @@ static const char *to_code; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "add-location", no_argument, &line_comment, 1 }, { "directory", required_argument, NULL, 'D' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/urlget.c gettext-tools/src/urlget.c --- gettext-tools/src/urlget.c 2005-05-20 16:44:41.000000000 -0400 +++ gettext-tools/src/urlget.c 2005-11-11 11:06:10.968750000 -0500 @@ -65,7 +65,7 @@ /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/src/xgettext.c gettext-tools/src/xgettext.c --- gettext-tools/src/xgettext.c 2005-05-20 16:47:42.000000000 -0400 +++ gettext-tools/src/xgettext.c 2005-11-11 11:06:25.406250000 -0500 @@ -176,7 +176,7 @@ #endif /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "add-comments", optional_argument, NULL, 'c' }, { "add-location", no_argument, &line_comment, 1 }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/tests/tstgettext.c gettext-tools/tests/tstgettext.c --- gettext-tools/tests/tstgettext.c 2005-05-20 16:48:17.000000000 -0400 +++ gettext-tools/tests/tstgettext.c 2005-11-11 11:10:29.046875000 -0500 @@ -52,7 +52,7 @@ static bool do_expand; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "domain", required_argument, NULL, 'd' }, { "env", required_argument, NULL, '=' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/tests/tstngettext.c gettext-tools/tests/tstngettext.c --- gettext-tools/tests/tstngettext.c 2005-05-20 16:48:20.000000000 -0400 +++ gettext-tools/tests/tstngettext.c 2005-11-11 11:10:39.875000000 -0500 @@ -42,7 +42,7 @@ #define _(str) gettext (str) /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "domain", required_argument, NULL, 'd' }, { "env", required_argument, NULL, '=' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-runtime/configure.ac gettext-runtime/configure.ac --- gettext-runtime/configure.ac 2005-11-11 00:04:26.000000000 -0500 +++ gettext-runtime/configure.ac 2005-11-11 11:34:46.687500000 -0500 @@ -111,6 +111,28 @@ #endif ]) +dnl Since gcc-3.3.3, const variables are placed in .rdata section +dnl On windows (cygwin, mingw) this is a problem if the variable +dnl is a composite containing references to other variables, because +dnl the runtime relocation machinery can't fixup the address. Thus +dnl these composite vars must NOT be declared const. This typically +dnl occurs in long_options structs, containing references to variables +dnl that are the targets of an option flag. +case "$host_os" in + *cygwin* | *mingw* ) + AC_DEFINE([CONST_IS_PROBLEMATIC_WIN32], 1, + [Define to 1 if structs-containing-references must not be declared const]) + ;; +esac +AH_VERBATIM([DEF_CONST_PROBLEMATIC_WIN32], +[/* On some platforms, structs-containing-references must not be declared const */ +#if defined CONST_IS_PROBLEMATIC_WIN32 +# define CONST_PROBLEMATIC_WIN32 +#else +# define CONST_PROBLEMATIC_WIN32 const +#endif +]) + AH_VERBATIM([DEF_OS2], [/* Extra OS/2 (emx+gcc) defines. */ #ifdef __EMX__ diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-tools/configure.ac gettext-tools/configure.ac --- gettext-tools/configure.ac 2005-11-11 00:26:09.000000000 -0500 +++ gettext-tools/configure.ac 2005-11-11 11:34:03.140625000 -0500 @@ -214,6 +214,28 @@ #endif ]) +dnl Since gcc-3.3.3, const variables are placed in .rdata section +dnl On windows (cygwin, mingw) this is a problem if the variable +dnl is a composite containing references to other variables, because +dnl the runtime relocation machinery can't fixup the address. Thus +dnl these composite vars must NOT be declared const. This typically +dnl occurs in long_options structs, containing references to variables +dnl that are the targets of an option flag. +case "$host_os" in + *cygwin* | *mingw* ) + AC_DEFINE([CONST_IS_PROBLEMATIC_WIN32], 1, + [Define to 1 if structs-containing-references must not be declared const]) + ;; +esac +AH_VERBATIM([DEF_CONST_PROBLEMATIC_WIN32], +[/* On some platforms, structs-containing-references must not be declared const */ +#if defined CONST_IS_PROBLEMATIC_WIN32 +# define CONST_PROBLEMATIC_WIN32 +#else +# define CONST_PROBLEMATIC_WIN32 const +#endif +]) + dnl Check for the expat XML parser. dnl On operating systems where binary distribution vendors are likely to dnl ship both gettext and expat, we use dynamic loading to avoid a hard diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-runtime/src/envsubst.c gettext-runtime/src/envsubst.c --- gettext-runtime/src/envsubst.c 2005-05-20 16:14:16.000000000 -0400 +++ gettext-runtime/src/envsubst.c 2005-11-11 11:07:50.796875000 -0500 @@ -43,7 +43,7 @@ static bool all_variables; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "variables", no_argument, NULL, 'v' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-runtime/src/gettext.c gettext-runtime/src/gettext.c --- gettext-runtime/src/gettext.c 2005-05-20 16:14:21.000000000 -0400 +++ gettext-runtime/src/gettext.c 2005-11-11 11:08:03.859375000 -0500 @@ -48,7 +48,7 @@ static bool do_expand; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "domain", required_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' }, diff -urN -x .build -x .inst -x .sinst -x '*~' gettext-runtime/src/ngettext.c gettext-runtime/src/ngettext.c --- gettext-runtime/src/ngettext.c 2005-05-20 16:14:39.000000000 -0400 +++ gettext-runtime/src/ngettext.c 2005-11-11 11:08:16.062500000 -0500 @@ -44,7 +44,7 @@ static int do_expand; /* Long options. */ -static const struct option long_options[] = +static CONST_PROBLEMATIC_WIN32 struct option long_options[] = { { "domain", required_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' },