[x264-devel] Eliminate some compiler warnings on BSD

Henrik Gramner git at videolan.org
Wed Apr 20 19:40:45 CEST 2016


x264 | branch: master | Henrik Gramner <henrik at gramner.com> | Wed Apr 13 17:53:49 2016 +0200| [2102de2584e03fce4abac49eb37d5d7a0803380f] | committer: Henrik Gramner

Eliminate some compiler warnings on BSD

Include <strings.h> in addition to <string.h>. According to the POSIX
specification the prototypes for strcasecmp() and strncasecmp() are
declared in <strings.h>. On some systems they are also declared in
<string.h> for compatibility reasons but we shouldn't rely on that.

Define _POSIX_C_SOURCE only when it's required to do so. Some BSD
variants doesn't declare certain function prototypes otherwise.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=2102de2584e03fce4abac49eb37d5d7a0803380f
---

 common/osdep.h |    2 ++
 configure      |    6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/common/osdep.h b/common/osdep.h
index 520710a..64e3431 100644
--- a/common/osdep.h
+++ b/common/osdep.h
@@ -60,6 +60,8 @@ int x264_vsnprintf( char *s, size_t n, const char *fmt, va_list arg );
 #define snprintf  x264_snprintf
 #define vsnprintf x264_vsnprintf
 #endif
+#else
+#include <strings.h>
 #endif
 
 #if !defined(va_copy) && defined(__INTEL_COMPILER)
diff --git a/configure b/configure
index f9856bd..7c01ebc 100755
--- a/configure
+++ b/configure
@@ -547,6 +547,9 @@ if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
         `$CC 2>&1 | grep -q 'x86'` && host_cpu=i486
         `$CC 2>&1 | grep -q 'x64'` && host_cpu=x86_64
         cpp_check '' '' '_MSC_VER > 1800 || (_MSC_VER == 1800 && _MSC_FULL_VER >= 180030324)' || die "Microsoft Visual Studio support requires Visual Studio 2013 Update 2 or newer"
+    else
+        # MinGW uses broken pre-VS2015 Microsoft printf functions unless it's told to use the POSIX ones.
+        CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L"
     fi
 else
     if [[ "$cc_base" = icc || "$cc_base" = icc[\ .]* ]]; then
@@ -570,7 +573,6 @@ case $host_os in
     darwin*)
         SYS="MACOSX"
         libm="-lm"
-        CFLAGS="$CFLAGS -D_DARWIN_C_SOURCE"
         if [ "$pic" = "no" ]; then
             cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
         fi
@@ -807,7 +809,7 @@ cc_check || die "No working C compiler found."
 
 if [ $compiler_style = GNU ]; then
     if cc_check '' -std=gnu99 'for( int i = 0; i < 9; i++ );' ; then
-        CFLAGS="$CFLAGS -std=gnu99 -D_POSIX_C_SOURCE=200112L -D_GNU_SOURCE"
+        CFLAGS="$CFLAGS -std=gnu99 -D_GNU_SOURCE"
     elif cc_check '' -std=c99 'for( int i = 0; i < 9; i++ );' ; then
         CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
     elif ! cc_check '' '' 'for( int i = 0; i < 9; i++ );' ; then



More information about the x264-devel mailing list