On 2/26/21 9:47 AM, Rémi Bernon wrote:
MinGW g++ requires initialized selectany to have extern linkage.
When supported, we define WCHAR as char16_t, which requires u"" string literal. When not supported, and when WCHAR is unsigned short, it then requires to use an array initializer instead of a L"" string literal.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
tools/widl/header.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/tools/widl/header.c b/tools/widl/header.c index a472af49066..8993038baca 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1836,8 +1836,18 @@ static void write_runtimeclass(FILE *header, type_t *runtimeclass) fprintf(header, "#ifndef 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, "#ifdef __cplusplus\n");
- fprintf(header, "#if defined(WINE_UNICODE_NATIVE)\n");
- fprintf(header, "extern const DECLSPEC_SELECTANY WCHAR RuntimeClass_%s[] = L"%s";\n", c_name, name);
- fprintf(header, "#else\n");
- 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]);
- fprintf(header, "0};\n");
- fprintf(header, "#endif\n");
- fprintf(header, "#else /* __cplusplus */\n"); /* 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, "#endif\n"); fprintf(header, "#else\n"); fprintf(header, "static const WCHAR RuntimeClass_%s[] = {", c_name); for (i = 0, len = strlen(name); i < len; ++i) fprintf(header, "'%c',", name[i]);
The commit comment is also a bit inaccurate too now, as I late folded the u"" string literal case with the array initializer, trying to keep things simple... Sorry.
Not sure if it's worth another version, the details could probably be cut, just tell me.