Commit 6966d7ea authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

widl: Fix C++ RuntimeClass string constants declaration.

MinGW g++ requires initialized selectany to have extern linkage. Also, because of the various ways WCHAR may be defined, using an array initializer is the simplest way to support all cases. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 6ed601cc
...@@ -1835,11 +1835,15 @@ static void write_runtimeclass(FILE *header, type_t *runtimeclass) ...@@ -1835,11 +1835,15 @@ static void write_runtimeclass(FILE *header, type_t *runtimeclass)
if (contract) write_apicontract_guard_start(header, contract); if (contract) write_apicontract_guard_start(header, contract);
fprintf(header, "#ifndef RUNTIMECLASS_%s_DEFINED\n", c_name); fprintf(header, "#ifndef RUNTIMECLASS_%s_DEFINED\n", c_name);
fprintf(header, "#define RUNTIMECLASS_%s_DEFINED\n", c_name); fprintf(header, "#define RUNTIMECLASS_%s_DEFINED\n", c_name);
fprintf(header, "#if defined(_MSC_VER) || defined(__MINGW32__)\n"); fprintf(header, "#if !defined(_MSC_VER) && !defined(__MINGW32__)\n");
fprintf(header, "static const WCHAR RuntimeClass_%s[] = {", c_name);
for (i = 0, len = strlen(name); i < len; ++i) fprintf(header, "'%c',", name[i]);
fprintf(header, "0};\n");
fprintf(header, "#elif defined(__GNUC__) && !defined(__cplusplus)\n");
/* FIXME: MIDL generates extern const here but GCC warns if extern is initialized */ /* FIXME: MIDL generates extern const here but GCC warns if extern is initialized */
fprintf(header, "const DECLSPEC_SELECTANY WCHAR RuntimeClass_%s[] = L\"%s\";\n", c_name, name); fprintf(header, "const DECLSPEC_SELECTANY WCHAR RuntimeClass_%s[] = L\"%s\";\n", c_name, name);
fprintf(header, "#else\n"); fprintf(header, "#else\n");
fprintf(header, "static const WCHAR RuntimeClass_%s[] = {", c_name); fprintf(header, "extern const DECLSPEC_SELECTANY WCHAR RuntimeClass_%s[] = {", c_name);
for (i = 0, len = strlen(name); i < len; ++i) fprintf(header, "'%c',", name[i]); for (i = 0, len = strlen(name); i < len; ++i) fprintf(header, "'%c',", name[i]);
fprintf(header, "0};\n"); fprintf(header, "0};\n");
fprintf(header, "#endif\n"); fprintf(header, "#endif\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment