]> git.sesse.net Git - x264/commitdiff
Eliminate some compiler warnings on BSD
authorHenrik Gramner <henrik@gramner.com>
Wed, 13 Apr 2016 15:53:49 +0000 (17:53 +0200)
committerHenrik Gramner <henrik@gramner.com>
Wed, 20 Apr 2016 15:15:51 +0000 (17:15 +0200)
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.

common/osdep.h
configure

index 520710a9783fb8cb0ff9e8e71e1eeaa16cf51bb6..64e34317bb08dd6995e71ed0b3049d15a2e414e2 100644 (file)
@@ -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)
index f9856bd7f55736313b82661ebffb046733cfba3f..7c01ebcba157c05aa1c0b05347bb9cd85001d4da 100755 (executable)
--- 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