Skip to content
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

Use uname(3) to get platform name via POSIX API #144

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

RealDeuce
Copy link

Since unix implies POSIX, and even POSIX.1 included uname(3), we can simply ask a POSIX system what the system name is.

While some compilers don't define unix for some platforms (ie: clang on macOS), it appears that every platform that defines unix at least has the POSIX unistd.h header.

Since __unix__ implies POSIX, and even POSIX.1 included uname(3),
we can simply ask a POSIX system what the system name is.

While some compilers don't define __unix__ for some platforms
(ie: clang on macOS), it appears that every platform that defines
__unix__ at least has the POSIX unistd.h header.
@RealDeuce
Copy link
Author

RealDeuce commented Mar 13, 2024

The __APPLE__ and __linux__ blocks could alse be switched to using uname, and the test for unistd.h could be expanded to #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) (as mentioned here), but there's presumably value in stable strings for the common targets (presumably, macOS returns "macOS" not "OS X" now for example).

Despite the test no longer running, the return value was still checked
by the test script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant