-
Notifications
You must be signed in to change notification settings - Fork 608
compiler.h changes for Windows MSVC support #6623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ | |
#error "You need C++17 to compile ExecuTorch" | ||
#endif | ||
|
||
#if defined(_WIN32) && (defined(min) || defined(max)) | ||
#if defined(_MSC_VER) && (defined(min) || defined(max)) | ||
#error \ | ||
"Macro clash with min and max -- define NOMINMAX when compiling your program on Windows" | ||
#endif | ||
|
@@ -100,22 +100,38 @@ | |
#endif // (__cplusplus) >= 202002L | ||
|
||
/// Define a C symbol with weak linkage. | ||
#ifdef _MSC_VER | ||
// There currently doesn't seem to be a great way to do this in Windows and | ||
// given that weak linkage is not really critical on Windows, we'll just leave | ||
// it as a stub. | ||
#define ET_WEAK | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, we are adding |
||
#else | ||
#define ET_WEAK __attribute__((weak)) | ||
#endif | ||
|
||
/** | ||
* Annotation marking a function as printf-like, providing compiler support | ||
* for format string argument checking. | ||
*/ | ||
#ifdef _MSC_VER | ||
#include <sal.h> | ||
#define ET_PRINTFLIKE(_string_index, _va_index) _Printf_format_string_ | ||
#else | ||
#define ET_PRINTFLIKE(_string_index, _va_index) \ | ||
__attribute__((format(printf, _string_index, _va_index))) | ||
|
||
/// Name of the source file without a directory string. | ||
#define ET_SHORT_FILENAME (__builtin_strrchr("/" __FILE__, '/') + 1) | ||
#endif | ||
|
||
#ifndef __has_builtin | ||
#define __has_builtin(x) (0) | ||
#endif | ||
|
||
#if __has_builtin(__builtin_strrchr) | ||
/// Name of the source file without a directory string. | ||
#define ET_SHORT_FILENAME (__builtin_strrchr("/" __FILE__, '/') + 1) | ||
#else | ||
#define ET_SHORT_FILENAME __FILE__ | ||
#endif | ||
|
||
#if __has_builtin(__builtin_LINE) | ||
/// Current line as an integer. | ||
#define ET_LINE __builtin_LINE() | ||
|
@@ -141,7 +157,7 @@ | |
#endif // ifndef | ||
|
||
// Define size_t and ssize_t. | ||
#ifndef _WIN32 | ||
#ifndef _MSC_VER | ||
#include <sys/types.h> | ||
#else | ||
#include <stddef.h> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels unrelated to PR in question, is it?