| 
80 | 80 |   [[deprecated("This API is experimental and may change without notice.")]]  | 
81 | 81 | #define ET_FALLTHROUGH [[fallthrough]]  | 
82 | 82 | #define ET_NODISCARD [[nodiscard]]  | 
 | 83 | + | 
 | 84 | +#if defined(__GNUC__) && (__GNUC__ < 9 || (__GNUC__ == 9 && __GNUC_MINOR__ < 3))  | 
 | 85 | +// GCC older than 9.3 has a bug that triggers a syntax error when using [[maybe_unused]]  | 
 | 86 | +// on the first parameter of a constructor:  | 
 | 87 | +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429  | 
 | 88 | +#define ET_UNUSED __attribute__((unused))  | 
 | 89 | +#else  | 
83 | 90 | #define ET_UNUSED [[maybe_unused]]  | 
 | 91 | +#endif  | 
84 | 92 | 
 
  | 
85 | 93 | // UNLIKELY Macro  | 
86 | 94 | // example  | 
 | 
100 | 108 | #endif // (__cplusplus) >= 202002L  | 
101 | 109 | 
 
  | 
102 | 110 | /// Define a C symbol with weak linkage.  | 
 | 111 | +#ifdef _WIN32  | 
 | 112 | +// There currently doesn't seem to be a great way to do this in Windows and given  | 
 | 113 | +// that weak linkage is not really critical on Windows, we'll just leave it as a stub.  | 
 | 114 | +#define ET_WEAK  | 
 | 115 | +#else  | 
103 | 116 | #define ET_WEAK __attribute__((weak))  | 
 | 117 | +#endif  | 
104 | 118 | 
 
  | 
105 | 119 | /**  | 
106 | 120 |  * Annotation marking a function as printf-like, providing compiler support  | 
107 | 121 |  * for format string argument checking.  | 
108 | 122 |  */  | 
 | 123 | +#ifdef _WIN32  | 
 | 124 | +#include <sal.h>  | 
 | 125 | +#define ET_PRINTFLIKE(_string_index, _va_index) _Printf_format_string_  | 
 | 126 | +#else  | 
109 | 127 | #define ET_PRINTFLIKE(_string_index, _va_index) \  | 
110 | 128 |   __attribute__((format(printf, _string_index, _va_index)))  | 
111 |  | - | 
112 |  | -/// Name of the source file without a directory string.  | 
113 |  | -#define ET_SHORT_FILENAME (__builtin_strrchr("/" __FILE__, '/') + 1)  | 
 | 129 | +#endif  | 
114 | 130 | 
 
  | 
115 | 131 | #ifndef __has_builtin  | 
116 | 132 | #define __has_builtin(x) (0)  | 
117 | 133 | #endif  | 
118 | 134 | 
 
  | 
 | 135 | +#if __has_builtin(__builtin_strrchr)  | 
 | 136 | +/// Name of the source file without a directory string.  | 
 | 137 | +#define ET_SHORT_FILENAME (__builtin_strrchr("/" __FILE__, '/') + 1)  | 
 | 138 | +#else  | 
 | 139 | +#include <cstring>  | 
 | 140 | +#define ET_SHORT_FILENAME (strchr("/" __FILE__, '/') + 1)  | 
 | 141 | +#endif  | 
 | 142 | + | 
119 | 143 | #if __has_builtin(__builtin_LINE)  | 
120 | 144 | /// Current line as an integer.  | 
121 | 145 | #define ET_LINE __builtin_LINE()  | 
 | 
0 commit comments