Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pngcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
# endif
#endif

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 ;-)

# include <unistd.h> /* isatty() */
#endif
#if defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
Expand Down
Loading