|  | 
| 36 | 36 | #error "You need C++17 to compile ExecuTorch" | 
| 37 | 37 | #endif | 
| 38 | 38 | 
 | 
| 39 |  | -#if defined(_WIN32) && (defined(min) || defined(max)) | 
|  | 39 | +#if defined(_MSC_VER) && (defined(min) || defined(max)) | 
| 40 | 40 | #error \ | 
| 41 | 41 |     "Macro clash with min and max -- define NOMINMAX when compiling your program on Windows" | 
| 42 | 42 | #endif | 
|  | 
| 100 | 100 | #endif // (__cplusplus) >= 202002L | 
| 101 | 101 | 
 | 
| 102 | 102 | /// Define a C symbol with weak linkage. | 
|  | 103 | +#ifdef _MSC_VER | 
|  | 104 | +// There currently doesn't seem to be a great way to do this in Windows and | 
|  | 105 | +// given that weak linkage is not really critical on Windows, we'll just leave | 
|  | 106 | +// it as a stub. | 
|  | 107 | +#define ET_WEAK | 
|  | 108 | +#else | 
| 103 | 109 | #define ET_WEAK __attribute__((weak)) | 
|  | 110 | +#endif | 
| 104 | 111 | 
 | 
| 105 | 112 | /** | 
| 106 | 113 |  * Annotation marking a function as printf-like, providing compiler support | 
| 107 | 114 |  * for format string argument checking. | 
| 108 | 115 |  */ | 
|  | 116 | +#ifdef _MSC_VER | 
|  | 117 | +#include <sal.h> | 
|  | 118 | +#define ET_PRINTFLIKE(_string_index, _va_index) _Printf_format_string_ | 
|  | 119 | +#else | 
| 109 | 120 | #define ET_PRINTFLIKE(_string_index, _va_index) \ | 
| 110 | 121 |   __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) | 
|  | 122 | +#endif | 
| 114 | 123 | 
 | 
| 115 | 124 | #ifndef __has_builtin | 
| 116 | 125 | #define __has_builtin(x) (0) | 
| 117 | 126 | #endif | 
| 118 | 127 | 
 | 
|  | 128 | +#if __has_builtin(__builtin_strrchr) | 
|  | 129 | +/// Name of the source file without a directory string. | 
|  | 130 | +#define ET_SHORT_FILENAME (__builtin_strrchr("/" __FILE__, '/') + 1) | 
|  | 131 | +#else | 
|  | 132 | +#define ET_SHORT_FILENAME __FILE__ | 
|  | 133 | +#endif | 
|  | 134 | + | 
| 119 | 135 | #if __has_builtin(__builtin_LINE) | 
| 120 | 136 | /// Current line as an integer. | 
| 121 | 137 | #define ET_LINE __builtin_LINE() | 
|  | 
| 141 | 157 | #endif // ifndef | 
| 142 | 158 | 
 | 
| 143 | 159 | // Define size_t and ssize_t. | 
| 144 |  | -#ifndef _WIN32 | 
|  | 160 | +#ifndef _MSC_VER | 
| 145 | 161 | #include <sys/types.h> | 
| 146 | 162 | #else | 
| 147 | 163 | #include <stddef.h> | 
|  | 
0 commit comments