MIDL generates enum typedefs without a prior type declaration, as well as using explicit enum underlying type specifier. None of this is supported in MinGW.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
AFAIK the patch has been requested and used by MinGW users to fix their WinRT generated headers with C++ code.
This does the following kind of changes to the headers:
diff --git a/windows.devices.enumeration.h b/windows.devices.enumeration.h index fc7e8c4..981c5c3 100644 --- a/windows.devices.enumeration.h +++ b/windows.devices.enumeration.h @@ -248,31 +248,11 @@ typedef interface __FITypedEventHandler_2_Windows__CDevices__CEnumeration__CDevi extern "C" { #endif
-#ifdef __cplusplus -namespace ABI {
- namespace Windows {
namespace Devices {
namespace Enumeration {
typedef enum DeviceWatcherStatus DeviceWatcherStatus;
}
}
- }
-} -#else /* __cplusplus */ +#ifndef __cplusplus typedef enum __x_ABI_CWindows_CDevices_CEnumeration_CDeviceWatcherStatus __x_ABI_CWindows_CDevices_CEnumeration_CDeviceWatcherStatus #endif /* __cplusplus */
-#ifdef __cplusplus -namespace ABI {
- namespace Windows {
namespace Devices {
namespace Enumeration {
typedef enum Panel Panel;
}
}
- }
-} -#else /* __cplusplus */ +#ifndef __cplusplus typedef enum __x_ABI_CWindows_CDevices_CEnumeration_CPanel __x_ABI_CWindows_CDevices_CEnumeration_CPanel; #endif /* __cplusplus */
tools/widl/header.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index f8dcab91e6a..4a59cb9162a 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -872,22 +872,28 @@ static void write_typedef(FILE *header, type_t *type, int declonly) type_t *t = type_alias_get_aliasee_type(type); if (winrt_mode && t->namespace && !is_global_namespace(t->namespace)) { - fprintf(header, "#ifdef __cplusplus\n"); - write_namespace_start(header, t->namespace); - indent(header, 0); - } - fprintf(header, "typedef "); - write_type_v(header, type_alias_get_aliasee(type), FALSE, declonly, type->name, NAME_DEFAULT); - fprintf(header, ";\n"); - if (winrt_mode && t->namespace && !is_global_namespace(t->namespace)) - { - write_namespace_end(header, t->namespace); - fprintf(header, "#else /* __cplusplus */\n"); + fprintf(header, "#ifndef __cplusplus\n"); fprintf(header, "typedef "); write_type_v(header, type_alias_get_aliasee(type), FALSE, declonly, type->c_name, NAME_C); fprintf(header, ";\n"); + if (type_get_type_detect_alias(t) != TYPE_ENUM) + { + fprintf(header, "#else /* __cplusplus */\n"); + write_namespace_start(header, t->namespace); + indent(header, 0); + fprintf(header, "typedef "); + write_type_v(header, type_alias_get_aliasee(type), FALSE, declonly, type->name, NAME_DEFAULT); + fprintf(header, ";\n"); + write_namespace_end(header, t->namespace); + } fprintf(header, "#endif /* __cplusplus */\n\n"); } + else + { + fprintf(header, "typedef "); + write_type_v(header, type_alias_get_aliasee(type), FALSE, declonly, type->name, NAME_DEFAULT); + fprintf(header, ";\n"); + } }
int is_const_decl(const var_t *var)