|
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 | +#define ET_UNUSED __attribute__((unused)) |
| 86 | +#else |
83 | 87 | #define ET_UNUSED [[maybe_unused]]
|
| 88 | +#endif |
84 | 89 |
|
85 | 90 | // UNLIKELY Macro
|
86 | 91 | // example
|
|
100 | 105 | #endif // (__cplusplus) >= 202002L
|
101 | 106 |
|
102 | 107 | /// Define a C symbol with weak linkage.
|
| 108 | +#ifdef _WIN32 |
| 109 | +// There currently doesn't seem to be a great way to do this in Windows and given |
| 110 | +// that weak linkage is not really critical on Windows, we'll just leave it as a stub. |
| 111 | +#define ET_WEAK |
| 112 | +#else |
103 | 113 | #define ET_WEAK __attribute__((weak))
|
| 114 | +#endif |
104 | 115 |
|
105 | 116 | /**
|
106 | 117 | * Annotation marking a function as printf-like, providing compiler support
|
107 | 118 | * for format string argument checking.
|
108 | 119 | */
|
| 120 | +#ifdef _WIN32 |
| 121 | +#include <sal.h> |
| 122 | +#define ET_PRINTFLIKE(_string_index, _va_index) _Printf_format_string_ |
| 123 | +#else |
109 | 124 | #define ET_PRINTFLIKE(_string_index, _va_index) \
|
110 | 125 | __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) |
| 126 | +#endif |
114 | 127 |
|
115 | 128 | #ifndef __has_builtin
|
116 | 129 | #define __has_builtin(x) (0)
|
117 | 130 | #endif
|
118 | 131 |
|
| 132 | +#if __has_builtin(__builtin_strrchr) |
| 133 | +/// Name of the source file without a directory string. |
| 134 | +#define ET_SHORT_FILENAME (__builtin_strrchr("/" __FILE__, '/') + 1) |
| 135 | +#else |
| 136 | +#include <cstring> |
| 137 | +#define ET_SHORT_FILENAME (strchr("/" __FILE__, '/') + 1) |
| 138 | +#endif |
| 139 | + |
119 | 140 | #if __has_builtin(__builtin_LINE)
|
120 | 141 | /// Current line as an integer.
|
121 | 142 | #define ET_LINE __builtin_LINE()
|
|
0 commit comments