[PATCH libxtrans v2] configure: Also add -D_DEFAULT_SOURCE to .pc cflags to shut up glibc warnings

Kristian Høgsberg krh at bitplanet.net
Tue Mar 25 11:21:44 PDT 2014


On Tue, Mar 25, 2014 at 7:16 AM, Hans de Goede <hdegoede at redhat.com> wrote:
> The latest glibc considers _BSD_SOURCE deprecated, leading to the following
> warning being issued for pretty much every C-file in the xserver:
>
> In file included from /usr/include/stdint.h:25:0,
>                  from /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/stdint.h:9,
>                  from ../include/misc.h:81,
>                  from miexpose.c:82:
> /usr/include/features.h:145:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
>  # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
>    ^
>
> I've discussed this with the glibc developers and the prefered way of fixing
> this is by also defining _DEFAULT_SOURCE which is the new way of stating
> _BSD_SOURCE / _SVID_SOURCE .
>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>

Tested-by: Kristian Høgsberg <krh at bitplanet.net>
Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>

This makes the warnings go away for me and the patch does the right
thing according to features.h:

/* _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for
   _DEFAULT_SOURCE.  If _DEFAULT_SOURCE is present we do not
   issue a warning; the expectation is that the source is being
   transitioned to use the new macro.  */
#if (defined _BSD_SOURCE || defined _SVID_SOURCE) \
    && !defined _DEFAULT_SOURCE
# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
# undef  _DEFAULT_SOURCE
# define _DEFAULT_SOURCE        1
#endif

It's worth mentioning that there are development versions of glibc
that doesn't have the  !defined _DEFAULT_SOURCE part in the condition
and will warn even with this patch in Xtrans.  That's what I had when
I first tested the patch - Fedora RPM 0:2.19.90-3.fc21.  In that case,
get a more recent glibc development snapshot.  Upgrading to
2.19.90-7.fc21 fixed it for me.

Kristian

> ---
>  xtrans.pc.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xtrans.pc.in b/xtrans.pc.in
> index 90d19b1..b8d135b 100644
> --- a/xtrans.pc.in
> +++ b/xtrans.pc.in
> @@ -6,4 +6,4 @@ includedir=@includedir@
>  Name: XTrans
>  Description: Abstract network code for X
>  Version: @PACKAGE_VERSION@
> -Cflags: -I${includedir} -D_BSD_SOURCE @fchown_define@ @sticky_bit_define@
> +Cflags: -I${includedir} -D_DEFAULT_SOURCE -D_BSD_SOURCE @fchown_define@ @sticky_bit_define@
> --
> 1.9.0
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list