libsoundio
libsoundio copied to clipboard
Fix build on FreeBSD
When compiling os.c
on FreeBSD, you need to zap _POSIX_C_SOURCE
or else you get this:
[ 9%] Building C object CMakeFiles/unit_tests.dir/src/os.c.o
In file included from /tmp/libsoundio/src/os.c:74:
/usr/include/sys/event.h:61:2: error: unknown type name 'u_short'; did you mean
'short'?
u_short flags;
^
/usr/include/sys/event.h:62:2: error: unknown type name 'u_int'
u_int fflags;
^
/tmp/libsoundio/src/os.c:701:71: error: use of undeclared identifier
'MAP_ANONYMOUS'
...*address = (char*)mmap(NULL, actual_capacity * 2, PROT_NONE, MAP_ANONYMO...
^
3 errors generated.
Also, the (FreeBSD) system that I tested on had ALSA development libraries installed for some reason. Unfortunately, the libsoundio ALSA backend requires inotify, so...
[ 16%] Building C object CMakeFiles/unit_tests.dir/src/alsa.c.o
/tmp/libsoundio/src/alsa.c:12:10: fatal error: 'sys/inotify.h' file not
found
#include <sys/inotify.h>
^
1 error generated.
And then there was this curiosity:
[ 2%] Building C object CMakeFiles/unit_tests.dir/test/unit_tests.c.o
In file included from /tmp/libsoundio/test/unit_tests.c:3:
In file included from /tmp/libsoundio/src/soundio_private.h:24:
In file included from /tmp/libsoundio/src/alsa.h:16:
In file included from /usr/local/include/alsa/asoundlib.h:63:
/usr/local/include/alsa/pcm.h:597:19: error: zero size arrays are an extension
[-Werror,-Wzero-length-array]
unsigned int pos[0]; /**< channel position array */
^
1 error generated.
This last one is cleared by -Wno-zero-length-array
.
The first two issues are fixed here: libsoundio-fix-freebsd.patch.txt
I'd like to merge this. Could you open this patch as a pull request so that I can give you credit for your work?