[FFmpeg-devel] [PATCHv2] configure: add -D_DEFAULT_SOURCE to silence -Wcpp

Clément Bœsch u at pkh.me
Thu Sep 17 10:54:32 CEST 2015


On Wed, Sep 16, 2015 at 06:55:39PM -0400, Ganesh Ajjanagadde wrote:
> Glibc 2.20 onwards generates a deprecation warning for usage of _BSD_SOURCE and _SVID_SOURCE.
> The solution from man feature_test_macros is to define both _DEFAULT_SOURCE and the old macros.
> This change is done in configure while testing for Glibc. Doing it in source code
> would require __UCLIBC__ checks, etc since uclibc also defines __GLIBC__ and __GLIBC_MINOR__,
> so placing it in configure avoids the repeated checks.
> 
> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
> ---
>  configure                | 6 ++++++
>  libavformat/os_support.c | 1 -
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index cd6f629..0cd0a6c 100755
> --- a/configure
> +++ b/configure
> @@ -4520,6 +4520,12 @@ probe_libc(){
>      elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
>          eval ${pfx}libc_type=glibc
>          add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
> +        # define _DEFAULT_SOURCE for glibc 2.20 onwards to silence deprecation
> +        # warnings for _BSD_SOURCE and _SVID_SOURCE.
> +        if check_${pfx}cpp_condition features.h "(__GLIBC__ == 2 && __GLIBC_MINOR__ >= 20) \
> +            || (__GLIBC__ > 2)"; then
> +            add_${pfx}cppflags -D_DEFAULT_SOURCE
> +        fi

Is this adding _DEFAULT_SOURCE to every compiled file while it was scope
to a standalone source file before?

>      # MinGW headers can be installed on Cygwin, so check for newlib first.
>      elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
>          eval ${pfx}libc_type=newlib
> diff --git a/libavformat/os_support.c b/libavformat/os_support.c
> index 7950e44..3c22631 100644
> --- a/libavformat/os_support.c
> +++ b/libavformat/os_support.c
> @@ -21,7 +21,6 @@
>   */
>  
>  /* needed by inet_aton() */
> -#define _DEFAULT_SOURCE
>  #define _SVID_SOURCE
>  
>  #include "config.h"

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150917/618557e0/attachment.sig>


More information about the ffmpeg-devel mailing list