Skip to content

Commit 263545b

Browse files
authored
Do not include sysctl.h on Linux. (#660)
This PR ensures `<sys/sysctl.h>` is not included on Linux, where it generates compile-time diagnostics on distros/versions where it's still present. The diagnostic looks something like: ``` [5/5][100%][7.920s] Linking Swift shared library lib/libTesting.so <module-includes>:3:10: note: in file included from <module-includes>:3: 1 | #include "./Defines.h" 2 | #include "./Discovery.h" 3 | #include "./Includes.h" | `- note: in file included from <module-includes>:3: 4 | #include "./Stubs.h" 5 | #include "./TestSupport.h" /home/build-user/swift-testing/Sources/_TestingInternals/include/./Includes.h:61:10: note: in file included from /home/build-user/swift-testing/Sources/_TestingInternals/include/./Includes.h:61: 59 | 60 | #if __has_include(<sys/sysctl.h>) 61 | #include <sys/sysctl.h> | `- note: in file included from /home/build-user/swift-testing/Sources/_TestingInternals/include/./Includes.h:61: 62 | #endif 63 | ``` Since we don't use `sysctl()` on Linux (and it's been outright removed from the OS!), let's fix the diagnostic. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 770ff07 commit 263545b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/_TestingInternals/include/Includes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#include <sys/stat.h>
5858
#endif
5959

60-
#if __has_include(<sys/sysctl.h>)
60+
#if __has_include(<sys/sysctl.h>) && !defined(__linux__)
6161
#include <sys/sysctl.h>
6262
#endif
6363

0 commit comments

Comments
 (0)