wafsamba/replace: move __STDC_WANT_LIB_EXT1__ to CFLAGS
authorStefan Metzmacher <metze@samba.org>
Sun, 27 Jan 2019 19:27:42 +0000 (20:27 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 29 Jan 2019 21:09:07 +0000 (22:09 +0100)
This fixes the build of python bindings, which use memset_s()
(via ZERO_STRUCT).

In python bindings Python.h needs to be the first header, which means
is already includes string.h. Defining __STDC_WANT_LIB_EXT1__ in
replace.h is too late in that case.

This fixes the --check-c-compiler=gcc --picky-developer on FreeBSD 12.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
buildtools/wafsamba/wscript
lib/replace/replace.h

index 7b8fb01db5e8af2c45b5515b7ea286c40b6200cb..57d8a1504e186d7a5571e5ec8ece90faa7a2e2a0 100644 (file)
@@ -444,6 +444,15 @@ def configure(conf):
     conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
     conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)
 
+    #
+    # Needs to be defined before std*.h and string*.h are included
+    # As Python.h already brings string.h we need it in CFLAGS.
+    # See memset_s() details here:
+    # https://en.cppreference.com/w/c/string/byte/memset
+    #
+    if conf.CHECK_CFLAGS(['-D__STDC_WANT_LIB_EXT1__=1'] + conf.env.WERROR_CFLAGS):
+        conf.ADD_CFLAGS('-D__STDC_WANT_LIB_EXT1__=1')
+
     # on Tru64 certain features are only available with _OSF_SOURCE set to 1
     # and _XOPEN_SOURCE set to 600
     if conf.env['SYSTEM_UNAME_SYSNAME'] == 'OSF1':
index 76898f013f8e9af338f9edc00fb4ad55bc006d02..212ed265d4ab5e14ddb27c2cfda354c358cee239 100644 (file)
 #include <standards.h>
 #endif
 
-/* Needs to be defined before std*.h and string*.h are included */
-#define __STDC_WANT_LIB_EXT1__ 1
+/*
+ * Needs to be defined before std*.h and string*.h are included
+ * As it's also needed when Python.h is the first header we
+ * require a global -D__STDC_WANT_LIB_EXT1__=1
+ */
+#ifndef __STDC_WANT_LIB_EXT1__
+#error -D__STDC_WANT_LIB_EXT1__=1 required
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>