-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicitly test stray include paths from the host.
This in particular affects `__has_include` new in C++17, which is also how the test internally works. Tested files are chosen so that there is no chance that other OSes have matching header files by accident.
- Loading branch information
1 parent
84436d6
commit 998830e
Showing
2 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,44 @@ | ||
#if defined __has_include | ||
#if __has_include(<linux/netfilter.h>) | ||
#define HAS_LINUX_HEADER | ||
#endif | ||
#if __has_include(<winsock2.h>) | ||
#define HAS_WINDOWS_HEADER | ||
#endif | ||
#if __has_include(<mach/mach_time.h>) | ||
#define HAS_MACOS_HEADER | ||
#endif | ||
#endif | ||
|
||
#ifdef __linux__ | ||
struct zigbuild_is_linux { int x; }; | ||
struct zigbuild_is_linux { int x; }; | ||
#if defined __has_include && !defined HAS_LINUX_HEADER | ||
#error "linux targets are expected to have <linux/netfilter.h>" | ||
#endif | ||
#else | ||
#if defined __has_include && defined HAS_LINUX_HEADER | ||
#error "non-linux targets mistakenly have <linux/netfilter.h>, probably from host includes" | ||
#endif | ||
#endif | ||
|
||
#ifdef _WIN32 | ||
struct zigbuild_is_win32 { int x; }; | ||
struct zigbuild_is_win32 { int x; }; | ||
#if defined __has_include && !defined HAS_WINDOWS_HEADER | ||
#error "windows targets are expected to have <winsock2.h>" | ||
#endif | ||
#else | ||
#if defined __has_include && defined HAS_WINDOWS_HEADER | ||
#error "non-windows targets mistakenly have <winsock2.h>, probably from host includes" | ||
#endif | ||
#endif | ||
|
||
#if defined __APPLE__ && defined __MACH__ | ||
struct zigbuild_is_macos { int x; }; | ||
struct zigbuild_is_macos { int x; }; | ||
#if defined __has_include && !defined HAS_MACOS_HEADER | ||
#error "macos targets are expected to have <mach/mach_time.h>" | ||
#endif | ||
#else | ||
#if defined __has_include && defined HAS_MACOS_HEADER | ||
#error "non-macos targets mistakenly have <mach/mach_time.h>, probably from host includes" | ||
#endif | ||
#endif |