Skip to content

Fix build on NetBSD.#63

Open
0-wiz-0 wants to merge 1 commit intopnggroup:mainfrom
0-wiz-0:main
Open

Fix build on NetBSD.#63
0-wiz-0 wants to merge 1 commit intopnggroup:mainfrom
0-wiz-0:main

Conversation

@0-wiz-0
Copy link

@0-wiz-0 0-wiz-0 commented Dec 15, 2025

Include missing header of isatty().

Include missing header of isatty().
#endif

#if defined(unix) || (defined(__MWERKS__) && defined(macintosh)) /* pxm */
#if defined(unix) || defined(__NetBSD__) || (defined(__MWERKS__) && defined(macintosh)) /* pxm */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If my understanding is correct, a fix like this is necessary because NetBSD (likely via pkgsrc) builds with strict C standard flags, which don't define the non-standard unix macro.

But then, a more portable alternative that works on all Unix and Unix-ish systems, not just for NetBSD, should be checking __unix__ instead:

#if defined(unix) || defined(__unix__) || (defined(__MWERKS__) && defined(macintosh))  /* pxm */

Side observation: That __MWERKS__ && macintosh no longer belongs there, either. It should be this instead:

#if defined(__unix) || defined(__unix__) || defined(__APPLE__)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think NetBSD ever used unix, but I just tried and __unix__ works (default compiler flags). Should I update the PR or will you just fix the whole line yourself?

And yes, this was noticed when updating the pkgsrc package.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plain unix without any leading underscore stopped being an acceptable macro since ANSI C89, and probably even before that, because it was polluting the global namespace. It's either __unix or __unix__, depending on the actual Unix flavour, and I think all modern Unix compilers define both, so we should be good on that front.

Should I update the PR or will you just fix the whole line yourself?

I will make that change no problem -- unless you beat me to it ;-)

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.

2 participants