From: Ilya Leoshkevich Date: Tue, 28 Jun 2022 08:51:39 +0000 (+0200) Subject: Bump _POSIX_C_SOURCE to 200809 for strdup() X-Git-Tag: 2.1.0-beta1~205 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdcae54e5ab3803e1129bb65b3cfacc1a735e8a4;p=thirdparty%2Fzlib-ng.git Bump _POSIX_C_SOURCE to 200809 for strdup() Google Test uses strdup(), which makes building tests fail on a fresh MSYS2 setup: In file included from zlib-ng/_deps/googletest-src/googletest/include/gtest/internal/gtest-internal.h:40, from zlib-ng/_deps/googletest-src/googletest/include/gtest/gtest.h:62, from zlib-ng/test/test_compress.cc:17: zlib-ng/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function ‘char* testing::internal::posix::StrDup(const char*)’: zlib-ng/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2046:47: error: ‘strdup’ was not declared in this scope; did you mean ‘StrDup’? 2046 | inline char* StrDup(const char* src) { return strdup(src); } | ^~~~~~ | StrDup Bump _POSIX_C_SOURCE to enable this function. An alternative solution would be to define _POSIX_C_SOURCE in test/CMakeLists.txt, but having a bigger value for zlib-ng itself should not hurt. Include zbuild.h earlier in minideflate.c in order to make the new setting take effect for this file. --- diff --git a/test/minideflate.c b/test/minideflate.c index 148a27769..987e6121b 100644 --- a/test/minideflate.c +++ b/test/minideflate.c @@ -3,10 +3,11 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ +#include "zbuild.h" + #include #include -#include "zbuild.h" #include "zutil.h" #if defined(_WIN32) || defined(__CYGWIN__) diff --git a/zbuild.h b/zbuild.h index 82374b1f1..d82c1c388 100644 --- a/zbuild.h +++ b/zbuild.h @@ -3,7 +3,7 @@ #define _POSIX_SOURCE 1 /* fileno */ #ifndef _POSIX_C_SOURCE -# define _POSIX_C_SOURCE 200112L /* snprintf, posix_memalign */ +# define _POSIX_C_SOURCE 200809L /* snprintf, posix_memalign, strdup */ #endif #include