Skip to content

Commit 50f701c

Browse files
author
Christian Hergert
committed
build: fix warnings on glibc 2.19
glibc 2.19 complains about deprecation of both _GNU_SOURCE and _SVID_SOURCE defined. (_SVID_SOURCE comes from _BSD_SOURCE). This does a check for glibc and only defines _GNU_SOURCE if we are on glibc. _GNU_SOURCE covers all our bases from _BSD_SOURCE anyway.
1 parent ce07468 commit 50f701c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

build/autotools/CheckCompiler.m4

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ if test "$c_compiler" = "unknown"; then
3030
AC_MSG_ERROR([Compiler GCC >= 4.1 or Clang >= 3.3 is required for C compilation])
3131
fi
3232

33+
# GLibc 2.19 complains about both _BSD_SOURCE and _GNU_SOURCE. The _GNU_SOURCE
34+
# contains everything anyway. So just use that.
35+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
36+
#include <features.h>
37+
#ifndef __GLIBC__
38+
#error not glibc
39+
#endif
40+
]], [])],
41+
LIBC_FEATURES="-D_GNU_SOURCE",
42+
LIBC_FEATURES="-D_BSD_SOURCE")
43+
AC_SUBST(LIBC_FEATURES)
44+
3345
AC_C_CONST
3446
AC_C_INLINE
3547
AC_C_TYPEOF

src/Makefile.am

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ lib_LTLIBRARIES += libmongoc-1.0.la
99

1010
libmongoc_priv_la_CPPFLAGS = \
1111
-DMONGOC_COMPILATION \
12-
-D_BSD_SOURCE \
13-
-D_GNU_SOURCE \
12+
$(LIBC_FEATURES) \
1413
$(OPTIMIZE_CFLAGS) \
1514
-I$(top_srcdir)/src \
1615
-I$(top_srcdir)/src/mongoc \

0 commit comments

Comments
 (0)