guiddef.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /**
  2. * This file is part of the mingw-w64 runtime package.
  3. * No warranty is given; refer to the file DISCLAIMER within this package.
  4. */
  5. #ifndef GUID_DEFINED
  6. #define GUID_DEFINED
  7. /* Make sure __LONG32 is defined. */
  8. #include <_mingw.h>
  9. #ifdef __WIDL__
  10. typedef struct {
  11. unsigned long Data1;
  12. unsigned short Data2;
  13. unsigned short Data3;
  14. byte Data4[8];
  15. } GUID;
  16. #else
  17. typedef struct _GUID {
  18. unsigned __LONG32 Data1;
  19. unsigned short Data2;
  20. unsigned short Data3;
  21. unsigned char Data4[8];
  22. } GUID;
  23. #endif
  24. #endif
  25. #if defined(__cplusplus) && (USE___UUIDOF == 0)
  26. extern "C++" {
  27. #if __cpp_constexpr >= 200704l && __cpp_inline_variables >= 201606L
  28. __extension__ template<typename T> struct __mingw_uuidof_s;
  29. __extension__ template<typename T> constexpr const GUID &__mingw_uuidof();
  30. #else
  31. __extension__ template<typename T> const GUID &__mingw_uuidof();
  32. #endif
  33. }
  34. #endif
  35. #ifndef FAR
  36. #define FAR
  37. #endif
  38. #ifndef DECLSPEC_SELECTANY
  39. #define DECLSPEC_SELECTANY __declspec(selectany)
  40. #endif
  41. #ifndef EXTERN_C
  42. #ifdef __cplusplus
  43. #define EXTERN_C extern "C"
  44. #else
  45. #define EXTERN_C extern
  46. #endif
  47. #endif
  48. #ifdef DEFINE_GUID
  49. #undef DEFINE_GUID
  50. #endif
  51. #ifdef INITGUID
  52. #ifdef __cplusplus
  53. #define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) EXTERN_C const GUID DECLSPEC_SELECTANY name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
  54. #else
  55. #define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) const GUID DECLSPEC_SELECTANY name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
  56. #endif
  57. #else
  58. /* __declspec(selectany) must be applied to initialized objects on GCC 5 hence must not be used here. */
  59. #define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) EXTERN_C const GUID name
  60. #endif
  61. #define DEFINE_OLEGUID(name, l, w1, w2) DEFINE_GUID (name, l, w1, w2, 0xc0, 0, 0, 0, 0, 0, 0, 0x46)
  62. #ifndef _GUIDDEF_H_
  63. #define _GUIDDEF_H_
  64. #ifndef __LPGUID_DEFINED__
  65. #define __LPGUID_DEFINED__
  66. typedef GUID *LPGUID;
  67. #endif
  68. #ifndef __LPCGUID_DEFINED__
  69. #define __LPCGUID_DEFINED__
  70. typedef const GUID *LPCGUID;
  71. #endif
  72. #ifndef __IID_DEFINED__
  73. #define __IID_DEFINED__
  74. typedef GUID IID;
  75. typedef IID *LPIID;
  76. #define IID_NULL GUID_NULL
  77. #define IsEqualIID(riid1, riid2) IsEqualGUID (riid1, riid2)
  78. #ifndef CLSID_DEFINED
  79. #define CLSID_DEFINED
  80. typedef GUID CLSID;
  81. #endif
  82. typedef CLSID *LPCLSID;
  83. #define CLSID_NULL GUID_NULL
  84. #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID (rclsid1, rclsid2)
  85. typedef GUID FMTID;
  86. typedef FMTID *LPFMTID;
  87. #define FMTID_NULL GUID_NULL
  88. #define IsEqualFMTID(rfmtid1, rfmtid2) IsEqualGUID (rfmtid1, rfmtid2)
  89. #ifdef __WIDL_proxy
  90. #define __MIDL_CONST
  91. #else
  92. #define __MIDL_CONST const
  93. #endif
  94. #ifndef _REFGUID_DEFINED
  95. #define _REFGUID_DEFINED
  96. #ifdef __cplusplus
  97. #define REFGUID const GUID &
  98. #else
  99. #define REFGUID const GUID *__MIDL_CONST
  100. #endif
  101. #endif
  102. #ifndef _REFIID_DEFINED
  103. #define _REFIID_DEFINED
  104. #ifdef __cplusplus
  105. #define REFIID const IID &
  106. #else
  107. #define REFIID const IID *__MIDL_CONST
  108. #endif
  109. #endif
  110. #ifndef _REFCLSID_DEFINED
  111. #define _REFCLSID_DEFINED
  112. #ifdef __cplusplus
  113. #define REFCLSID const IID &
  114. #else
  115. #define REFCLSID const IID *__MIDL_CONST
  116. #endif
  117. #endif
  118. #ifndef _REFFMTID_DEFINED
  119. #define _REFFMTID_DEFINED
  120. #ifdef __cplusplus
  121. #define REFFMTID const IID &
  122. #else
  123. #define REFFMTID const IID *__MIDL_CONST
  124. #endif
  125. #endif
  126. #endif
  127. #ifndef __WIDL__
  128. #ifndef _SYS_GUID_OPERATORS_
  129. #define _SYS_GUID_OPERATORS_
  130. #include <string.h>
  131. #ifdef __cplusplus
  132. __inline int InlineIsEqualGUID (REFGUID rguid1, REFGUID rguid2) {
  133. return ((&rguid1.Data1)[0] == (&rguid2.Data1)[0] && (&rguid1.Data1)[1] == (&rguid2.Data1)[1] && (&rguid1.Data1)[2] == (&rguid2.Data1)[2] && (&rguid1.Data1)[3] == (&rguid2.Data1)[3]);
  134. }
  135. __inline int IsEqualGUID (REFGUID rguid1, REFGUID rguid2) {
  136. return !memcmp (&rguid1,&rguid2, sizeof (GUID));
  137. }
  138. #else
  139. #define InlineIsEqualGUID(rguid1, rguid2) ((&(rguid1)->Data1)[0] == (&(rguid2)->Data1)[0] && (&(rguid1)->Data1)[1] == (&(rguid2)->Data1)[1] && (&(rguid1)->Data1)[2] == (&(rguid2)->Data1)[2] && (&(rguid1)->Data1)[3] == (&(rguid2)->Data1)[3])
  140. #define IsEqualGUID(rguid1, rguid2) (!memcmp (rguid1, rguid2, sizeof (GUID)))
  141. #endif
  142. #ifdef __INLINE_ISEQUAL_GUID
  143. #undef IsEqualGUID
  144. #define IsEqualGUID(rguid1, rguid2) InlineIsEqualGUID (rguid1, rguid2)
  145. #endif
  146. #define IsEqualIID(riid1, riid2) IsEqualGUID (riid1, riid2)
  147. #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID (rclsid1, rclsid2)
  148. #if !defined (_SYS_GUID_OPERATOR_EQ_) && !defined (_NO_SYS_GUID_OPERATOR_EQ_)
  149. #define _SYS_GUID_OPERATOR_EQ_
  150. #ifdef __cplusplus
  151. __inline bool operator== (REFGUID guidOne, REFGUID guidOther) { return !!IsEqualGUID (guidOne, guidOther); }
  152. __inline bool operator!= (REFGUID guidOne, REFGUID guidOther) { return ! (guidOne == guidOther); }
  153. #endif
  154. #endif
  155. #endif
  156. #endif
  157. #endif