Adding _POSIX_C_SOURCE to CPPFLAGS globally produces all sorts of problems
since it causes certain system functions to be hidden on some (BSD) systems.
The solution is to only add the flag on systems that really require it, i.e.
glibc-based ones.
This change makes BSD systems compile out-of-the-box without the need for
adding specific flags manually. It also allows dropping a number of flags
set manually on a file-per-file basis, but were only present to work around
breakage introduced by the presence of _POSIX_C_SOURCE.
Also add _XOPEN_SOURCE to CPPFLAGS for glibc systems. We use XSI extensions
in several places already, so it is preferable to define it globally instead
of littering source files with individual #defines only needed for glibc.
... | ... |
@@ -1664,7 +1664,7 @@ LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' |
1664 | 1664 |
|
1665 | 1665 |
CC_O='-o $@' |
1666 | 1666 |
|
1667 |
-host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall' |
|
1667 |
+host_cflags='-D_ISOC99_SOURCE -O3 -g -Wall' |
|
1668 | 1668 |
host_libs='-lm' |
1669 | 1669 |
|
1670 | 1670 |
target_path='$(CURDIR)' |
... | ... |
@@ -2316,7 +2316,7 @@ if test "$?" != 0; then |
2316 | 2316 |
die "C compiler test failed." |
2317 | 2317 |
fi |
2318 | 2318 |
|
2319 |
-add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 |
|
2319 |
+add_cppflags -D_ISOC99_SOURCE |
|
2320 | 2320 |
check_cflags -std=c99 |
2321 | 2321 |
check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64 |
2322 | 2322 |
#include <stdlib.h> |
... | ... |
@@ -2364,7 +2364,6 @@ case $target_os in |
2364 | 2364 |
disable symver |
2365 | 2365 |
oss_indev_extralibs="-lossaudio" |
2366 | 2366 |
oss_outdev_extralibs="-lossaudio" |
2367 |
- add_cppflags -D_XOPEN_SOURCE=600 |
|
2368 | 2367 |
;; |
2369 | 2368 |
openbsd) |
2370 | 2369 |
enable malloc_aligned |
... | ... |
@@ -2457,6 +2456,7 @@ case $target_os in |
2457 | 2457 |
enable dos_paths |
2458 | 2458 |
;; |
2459 | 2459 |
linux) |
2460 |
+ add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 |
|
2460 | 2461 |
enable dv1394 |
2461 | 2462 |
;; |
2462 | 2463 |
irix*) |
... | ... |
@@ -785,14 +785,6 @@ to configure. |
785 | 785 |
BSD make will not build Libav, you need to install and use GNU Make |
786 | 786 |
(@file{gmake}). |
787 | 787 |
|
788 |
-@subsubsection FreeBSD, DragonFly BSD |
|
789 |
- |
|
790 |
-These systems will not compile out-of-the-box due to broken system headers. |
|
791 |
-Passing @code{--extra-cflags=-D__BSD_VISIBLE} to configure will work |
|
792 |
-around the problem. This may have unexpected sideeffects, so use it at |
|
793 |
-your own risk. If you care about FreeBSD, please make an attempt at |
|
794 |
-getting the system headers fixed. |
|
795 |
- |
|
796 | 788 |
@subsection (Open)Solaris |
797 | 789 |
|
798 | 790 |
GNU Make is required to build Libav, so you have to invoke (@file{gmake}), |
... | ... |
@@ -24,10 +24,6 @@ |
24 | 24 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
25 | 25 |
*/ |
26 | 26 |
|
27 |
-#define _BSD_SOURCE 1 |
|
28 |
-#define _NETBSD_SOURCE |
|
29 |
-#define _XOPEN_SOURCE 600 |
|
30 |
- |
|
31 | 27 |
#include "libavformat/avformat.h" |
32 | 28 |
#if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H |
33 | 29 |
# include <dev/bktr/ioctl_meteor.h> |
... | ... |
@@ -19,9 +19,8 @@ |
19 | 19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | 20 |
*/ |
21 | 21 |
|
22 |
-/* needed for usleep() */ |
|
23 |
-#define _XOPEN_SOURCE 600 |
|
24 | 22 |
#include <unistd.h> |
23 |
+ |
|
25 | 24 |
#include "libavutil/avstring.h" |
26 | 25 |
#include "libavutil/opt.h" |
27 | 26 |
#include "os_support.h" |
... | ... |
@@ -25,7 +25,7 @@ |
25 | 25 |
*/ |
26 | 26 |
|
27 | 27 |
#define _BSD_SOURCE /* Needed for using struct ip_mreq with recent glibc */ |
28 |
-#define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */ |
|
28 |
+ |
|
29 | 29 |
#include "avformat.h" |
30 | 30 |
#include "avio_internal.h" |
31 | 31 |
#include "libavutil/parseutils.h" |
... | ... |
@@ -18,8 +18,6 @@ |
18 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | 19 |
*/ |
20 | 20 |
|
21 |
-#define _SVID_SOURCE //needed for MAP_ANONYMOUS |
|
22 |
-#define _DARWIN_C_SOURCE // needed for MAP_ANON |
|
23 | 21 |
#include <inttypes.h> |
24 | 22 |
#include <string.h> |
25 | 23 |
#include <math.h> |