Skip to content

Conversation

ismaell
Copy link
Contributor

@ismaell ismaell commented Jun 12, 2024

On musl libc

popen and pclose aren't exposed by musl libc unless one of the following macros is defined:

#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
 || defined(_BSD_SOURCE)

On Glibc

According to manpage popen(3) on Linux man-pages 6.05.01 :

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       popen(), pclose():
           _POSIX_C_SOURCE >= 2
               || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

Notes

  • _POSIX_SOURCE has been superseded by _POSIX_C_SOURCE.
  • _POSIX_C_SOURCE with a value of 2 is the option that potentially causes the least namespace contamination.

See feature_test_macros(7) for more information about the macros.

@ismaell
Copy link
Contributor Author

ismaell commented Jun 12, 2024

Seems the Mac OS X libc is broken. _POSIX_C_SOURCE == 2 means POSIX.2-1992 which should make the snprintf and vsnprintf functions available.

popen and pclose aren't exposed by musl libc unless one of the following
macros is defined:

	#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
	 || defined(_X_OPEN_SOURCE) || defined(_GNU_SOURCE) \
	 || defined(_BSD_SOURCE)

According to popen(3) on Linux man-pages 6.05.01:

	Feature Test Macro Requirements for glibc (...):

	    popen(), pclose():
	        _POSIX_C_SOURCE >= 2
                    || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

Notes:
* _POSIX_SOURCE has been superseded by _POSIX_C_SOURCE.
* _POSIX_C_SOURCE with a value of 2 (POSIX.2-1992) is the option that
  potentially causes the least namespace contamination.
* Seems the Mac OS X libc is broken: it hides snprintf/vsnprintf with
  _POSIX_C_SOURCE == 2, which is presumably wrong.

See feature_test_macros(7) for more information about the macros.
@andreas-jonsson
Copy link
Collaborator

Yea. I do find strange things on OSX sometimes. :)

@andreas-jonsson andreas-jonsson merged commit 23d3412 into virtualxt:develop Jun 15, 2024
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