From 5c4e082e9ecf826cf2aac3e1808e718353a579cf Mon Sep 17 00:00:00 2001 From: Tom Sullivan Date: Fri, 1 Jul 2022 15:08:42 +1000 Subject: [PATCH] Use feature test to expose `setenv` As per the [man page](https://man7.org/linux/man-pages/man3/setenv.3.html), `setenv` requires `_POSIX_C_SOURCE` >= 200112L to be defined before including the appropriate header file (`stdlib.h`). As the other included header files include some standard headers transitively, this needs to go above all includes. --- src/settings_test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/settings_test.c b/src/settings_test.c index 1cd3fd7..80402b9 100644 --- a/src/settings_test.c +++ b/src/settings_test.c @@ -1,3 +1,5 @@ +#define _POSIX_C_SOURCE 200112L + #include "settings.h" #include "acutest.h" @@ -6,9 +8,6 @@ #include -// Not sure why this declaration isn't pulled in? -extern int setenv(const char*, const char*, int); - static void create_mock_languages_dir(const char* root, const char** dirs, int dirs_length) { mkdir(root, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);