Skip to content

Commit 19aa228

Browse files
tarun292facebook-github-bot
authored andcommitted
compiler.h changes for Windows MSVC support (#6623)
Summary: Pull Request resolved: #6623 Differential Revision: D65328573
1 parent 97a4600 commit 19aa228

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

runtime/platform/compiler.h

+17-3
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,36 @@
100100
#endif // (__cplusplus) >= 202002L
101101

102102
/// Define a C symbol with weak linkage.
103+
#ifdef _WIN32
104+
#define ET_WEAK
105+
#else
103106
#define ET_WEAK __attribute__((weak))
107+
#endif
104108

105109
/**
106110
* Annotation marking a function as printf-like, providing compiler support
107111
* for format string argument checking.
108112
*/
113+
#ifdef _MSC_VER
114+
#include <sal.h>
115+
#define ET_PRINTFLIKE(_string_index, _va_index) _Printf_format_string_
116+
#else
109117
#define ET_PRINTFLIKE(_string_index, _va_index) \
110118
__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)
119+
#endif
114120

115121
#ifndef __has_builtin
116122
#define __has_builtin(x) (0)
117123
#endif
118124

125+
#if __has_builtin(__builtin_strrchr)
126+
/// Name of the source file without a directory string.
127+
#define ET_SHORT_FILENAME (__builtin_strrchr("/" __FILE__, '/') + 1)
128+
#else
129+
#include <cstring>
130+
#define ET_SHORT_FILENAME (strchr("/" __FILE__, '/') + 1)
131+
#endif
132+
119133
#if __has_builtin(__builtin_LINE)
120134
/// Current line as an integer.
121135
#define ET_LINE __builtin_LINE()

0 commit comments

Comments
 (0)