github-gist
github-gist copied to clipboard
xsel.c:372:14: error: 'fork' is deprecated: Use posix_spawn or fork
xsel 1.2.0 does not build on macOS Monterey. The error is:
xsel.c:372:14: error: 'fork' is deprecated: Use posix_spawn or fork [-Werror,-Wdeprecated-declarations]
if ((pid = fork()) == -1) {
^
This was reported to MacPorts here.
This seems to be with the macro generated by autoconf in config.h?
#define vfork fork
This is renaming vfork in <unistd.h> to fork hence the odd message deprecation message: fork is deprecated... use posix_spawn or fork
So it seems that there's a number of options?
- Remove
AC_FUNC_FORKfromconfigure.ac -
#undef vforkif you're macOS 12+ before#include <unistd.h> - Define
_POSIX_C_SOURCEbefore<unistd.h>.200112L` seems to work here. - Put the
config.hinclude after the system headers. Don't that's right since autoconf is trying to "fix things" - Or is this an autoconf bug? Should autoconf not create a
#define vfork forkmacro if it's macOS 12+?