Clang in MSVC mode supports this and __uuidof fails / complains about missing virtual destructor otherwise.
-- v2: include: Add DECLSPEC_UUID/DECLSPEC_NOVTABLE to MIDL_INTERFACE. include: Use winnt.h DECLSPEC_NOVTABLE definition in rpcndr.h. include: Use winnt.h DECLSPEC_UUID definition in rpcndr.h. include: Introduce a new __has_declspec_attribute macro.
From: Rémi Bernon rbernon@codeweavers.com
--- include/winnt.h | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/include/winnt.h b/include/winnt.h index df5113051d2..b03a92a9a7f 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -42,6 +42,14 @@ extern "C" { #endif
+#ifndef __has_declspec_attribute +# if defined(_MSC_VER) +# define __has_declspec_attribute(x) 1 +# else +# define __has_declspec_attribute(x) 0 +# endif +#endif + #if defined(_NTSYSTEM_) || defined(WINE_UNIX_LIB) #define NTSYSAPI DECLSPEC_EXPORT #else @@ -52,7 +60,7 @@ extern "C" { #define FASTCALL __fastcall
#ifndef DECLSPEC_IMPORT -# if defined(_MSC_VER) +# if __has_declspec_attribute(dllimport) # define DECLSPEC_IMPORT __declspec(dllimport) # elif defined(__MINGW32__) || defined(__CYGWIN__) # define DECLSPEC_IMPORT __attribute__((dllimport)) @@ -64,7 +72,7 @@ extern "C" { #endif
#ifndef DECLSPEC_NORETURN -# if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS) +# if __has_declspec_attribute(noreturn) && !defined(MIDL_PASS) # define DECLSPEC_NORETURN __declspec(noreturn) # elif defined(__GNUC__) # define DECLSPEC_NORETURN __attribute__((noreturn)) @@ -74,7 +82,7 @@ extern "C" { #endif
#ifndef DECLSPEC_ALIGN -# if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) +# if __has_declspec_attribute(align) && !defined(MIDL_PASS) # define DECLSPEC_ALIGN(x) __declspec(align(x)) # elif defined(__GNUC__) # define DECLSPEC_ALIGN(x) __attribute__((aligned(x))) @@ -84,7 +92,7 @@ extern "C" { #endif
#ifndef DECLSPEC_NOTHROW -# if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS) +# if __has_declspec_attribute(nothrow) && !defined(MIDL_PASS) # define DECLSPEC_NOTHROW __declspec(nothrow) # elif defined(__GNUC__) # define DECLSPEC_NOTHROW __attribute__((nothrow)) @@ -98,7 +106,7 @@ extern "C" { #endif
#ifndef DECLSPEC_UUID -# if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus) +# if __has_declspec_attribute(uuid) && defined (__cplusplus) # define DECLSPEC_UUID(x) __declspec(uuid(x)) # else # define DECLSPEC_UUID(x) @@ -106,7 +114,7 @@ extern "C" { #endif
#ifndef DECLSPEC_NOVTABLE -# if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus) +# if __has_declspec_attribute(novtable) && defined(__cplusplus) # define DECLSPEC_NOVTABLE __declspec(novtable) # else # define DECLSPEC_NOVTABLE @@ -114,7 +122,7 @@ extern "C" { #endif
#ifndef DECLSPEC_SELECTANY -#if defined(_MSC_VER) && (_MSC_VER >= 1100) +# if __has_declspec_attribute(selectany) #define DECLSPEC_SELECTANY __declspec(selectany) #elif defined(__MINGW32__) #define DECLSPEC_SELECTANY __attribute__((selectany)) @@ -138,7 +146,7 @@ extern "C" { #endif
#ifndef DECLSPEC_ADDRSAFE -# if defined(_MSC_VER) && (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64)) +# if __has_declspec_attribute(address_safe) && (defined(_M_ALPHA) || defined(_M_AXP64)) # define DECLSPEC_ADDRSAFE __declspec(address_safe) # else # define DECLSPEC_ADDRSAFE @@ -156,7 +164,7 @@ extern "C" { #endif
#ifndef DECLSPEC_NOINLINE -# if defined(_MSC_VER) && (_MSC_VER >= 1300) +# if __has_declspec_attribute(noinline) # define DECLSPEC_NOINLINE __declspec(noinline) # elif defined(__GNUC__) # define DECLSPEC_NOINLINE __attribute__((noinline)) @@ -166,7 +174,7 @@ extern "C" { #endif
#ifndef DECLSPEC_DEPRECATED -# if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) +# if __has_declspec_attribute(deprecated) && !defined(MIDL_PASS) # define DECLSPEC_DEPRECATED __declspec(deprecated) # define DEPRECATE_SUPPORTED # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2))) @@ -183,7 +191,7 @@ extern "C" { #if defined(__WINESRC__) && !defined(WINE_UNIX_LIB) /* Wine uses .spec file for PE exports */ # define DECLSPEC_EXPORT -#elif defined(_MSC_VER) +#elif __has_declspec_attribute(dllexport) # define DECLSPEC_EXPORT __declspec(dllexport) #elif defined(__MINGW32__) # define DECLSPEC_EXPORT __attribute__((dllexport)) @@ -206,7 +214,7 @@ extern "C" { #ifndef DECLSPEC_CHPE_PATCHABLE # ifndef __arm64ec__ # define DECLSPEC_CHPE_PATCHABLE -# elif defined(_MSC_VER) +# elif __has_declspec_attribute(hybrid_patchable) # define DECLSPEC_CHPE_PATCHABLE __declspec(hybrid_patchable) # else # define DECLSPEC_CHPE_PATCHABLE __attribute__((hybrid_patchable))
From: Rémi Bernon rbernon@codeweavers.com
--- include/rpcndr.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/rpcndr.h b/include/rpcndr.h index 93ebb0a4aa7..db4a2962eee 100644 --- a/include/rpcndr.h +++ b/include/rpcndr.h @@ -30,6 +30,14 @@ extern "C" { #endif
+#ifndef __has_declspec_attribute +# if defined(_MSC_VER) +# define __has_declspec_attribute(x) 1 +# else +# define __has_declspec_attribute(x) 0 +# endif +#endif + #undef CONST_VTBL #ifdef CONST_VTABLE # define CONST_VTBL const @@ -112,7 +120,14 @@ typedef void (__RPC_USER *NDR_RUNDOWN)(void *context); typedef void (__RPC_USER *NDR_NOTIFY_ROUTINE)(void); typedef void (__RPC_USER *NDR_NOTIFY2_ROUTINE)(boolean flag);
-#define DECLSPEC_UUID(x) +#ifndef DECLSPEC_UUID +# if __has_declspec_attribute(uuid) && defined (__cplusplus) +# define DECLSPEC_UUID(x) __declspec(uuid(x)) +# else +# define DECLSPEC_UUID(x) +# endif +#endif + #define MIDL_INTERFACE(x) struct
struct _MIDL_STUB_MESSAGE;
From: Rémi Bernon rbernon@codeweavers.com
--- include/rpcndr.h | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/include/rpcndr.h b/include/rpcndr.h index db4a2962eee..568d195d7d4 100644 --- a/include/rpcndr.h +++ b/include/rpcndr.h @@ -120,6 +120,14 @@ typedef void (__RPC_USER *NDR_RUNDOWN)(void *context); typedef void (__RPC_USER *NDR_NOTIFY_ROUTINE)(void); typedef void (__RPC_USER *NDR_NOTIFY2_ROUTINE)(boolean flag);
+#ifndef DECLSPEC_NOVTABLE +# if __has_declspec_attribute(novtable) && defined(__cplusplus) +# define DECLSPEC_NOVTABLE __declspec(novtable) +# else +# define DECLSPEC_NOVTABLE +# endif +#endif + #ifndef DECLSPEC_UUID # if __has_declspec_attribute(uuid) && defined (__cplusplus) # define DECLSPEC_UUID(x) __declspec(uuid(x))
From: Rémi Bernon rbernon@codeweavers.com
--- include/rpcndr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/rpcndr.h b/include/rpcndr.h index 568d195d7d4..1f525f1cb68 100644 --- a/include/rpcndr.h +++ b/include/rpcndr.h @@ -136,7 +136,7 @@ typedef void (__RPC_USER *NDR_NOTIFY2_ROUTINE)(boolean flag); # endif #endif
-#define MIDL_INTERFACE(x) struct +#define MIDL_INTERFACE(x) struct DECLSPEC_UUID(x) DECLSPEC_NOVTABLE
struct _MIDL_STUB_MESSAGE; struct _MIDL_STUB_DESC;
This merge request was approved by Jacek Caban.