Module: wine Branch: master Commit: 6966d7ea0821969ed4f2449fafd1197141e4bb62 URL: https://source.winehq.org/git/wine.git/?a=commit;h=6966d7ea0821969ed4f2449fa...
Author: Rémi Bernon rbernon@codeweavers.com Date: Fri Feb 26 15:36:42 2021 +0100
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: Rémi Bernon rbernon@codeweavers.com Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
tools/widl/header.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index a472af49066..cb0dc2f43a3 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1835,11 +1835,15 @@ static void write_runtimeclass(FILE *header, type_t *runtimeclass) if (contract) write_apicontract_guard_start(header, contract); 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, "#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 */ fprintf(header, "const DECLSPEC_SELECTANY WCHAR RuntimeClass_%s[] = L"%s";\n", c_name, name); 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]); fprintf(header, "0};\n"); fprintf(header, "#endif\n");