Clang in MSVC mode supports this and __uuidof fails / complains about missing virtual destructor otherwise.
From: Rémi Bernon rbernon@codeweavers.com
--- include/rpcndr.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/rpcndr.h b/include/rpcndr.h index 93ebb0a4aa7..9fcdf706709 100644 --- a/include/rpcndr.h +++ b/include/rpcndr.h @@ -112,7 +112,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 defined(_MSC_VER) && (_MSC_VER >= 1100) && 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 9fcdf706709..de6a0663650 100644 --- a/include/rpcndr.h +++ b/include/rpcndr.h @@ -112,6 +112,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 defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus) +# define DECLSPEC_NOVTABLE __declspec(novtable) +# else +# define DECLSPEC_NOVTABLE +# endif +#endif + #ifndef DECLSPEC_UUID # if defined(_MSC_VER) && (_MSC_VER >= 1100) && 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 de6a0663650..4d140492558 100644 --- a/include/rpcndr.h +++ b/include/rpcndr.h @@ -128,7 +128,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;
Jacek Caban (@jacek) commented about include/rpcndr.h:
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 defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
It's also supported on mingw targets when `-fms-extensions` is used. I think that using `__has_declspec_attribute` would be more portable and precise. Unfortunately, it's not supported on the actual MSVC, but maybe it's worth having something like: ``` #ifndef __has_declspec_attribute # #ifdef _MSC_VER # define __has_declspec_attribute(x) 1 # else # define __has_declspec_attribute(x) 0 # endif #endif ```
On Mon Sep 16 10:36:18 2024 +0000, Jacek Caban wrote:
It's also supported on mingw targets when `-fms-extensions` is used. I think that using `__has_declspec_attribute` would be more portable and precise. Unfortunately, it's not supported on the actual MSVC, but maybe it's worth having something like:
#ifndef __has_declspec_attribute # #ifdef _MSC_VER # define __has_declspec_attribute(x) 1 # else # define __has_declspec_attribute(x) 0 # endif #endif
Several of the DECLSPEC definitions also have additional conditions like _MSC_VER >= x, how would we handle these? Something like:
``` # if __has_declspec_attribute(noreturn) && (!defined(_MSC_VER) || (_MSC_VER >= 1200)) && !defined(MIDL_PASS) ```
Only looks worse.
On Mon Sep 16 11:02:46 2024 +0000, Rémi Bernon wrote:
Several of the DECLSPEC definitions also have additional conditions like _MSC_VER >= x, how would we handle these? Something like:
# if __has_declspec_attribute(noreturn) && (!defined(_MSC_VER) || (_MSC_VER >= 1200)) && !defined(MIDL_PASS)
Only looks worse.
In this case, using `__attribute__((noreturn))` should be just fine, so I don't think we need to change that at all.
On Mon Sep 16 11:30:30 2024 +0000, Jacek Caban wrote:
In this case, using `__attribute__((noreturn))` should be just fine, so I don't think we need to change that at all.
Well this one maybe, but there are others. DECLSPEC_UUID requires _MSC_VER >= 1100, should we drop that condition altogether? What about later, for instance (taking one without alternatives) DECLSPEC_ADDRSAFE which has a different version requirement?
On Mon Sep 16 11:54:44 2024 +0000, Rémi Bernon wrote:
Well this one maybe, but there are others. DECLSPEC_UUID requires _MSC_VER >= 1100, should we drop that condition altogether? What about later, for instance (taking one without alternatives) DECLSPEC_ADDRSAFE which has a different version requirement?
Yes, these can be dropped. We don't need to remain compatible with MSVC from 25 years ago.