Skip to content

Commit

Permalink
Define _GNU_SOURCE when needed
Browse files Browse the repository at this point in the history
Define _GNU_SOURCE to fix build with musl otherwise we'll got the
following build failures due to localtime_r, strnlen, gmtime_r and
asctime_r being undefined:

os/localtime_s.c:124:12: error: implicit declaration of function 'localtime_r'; did you mean 'localtime_s'? [-Werror=implicit-function-declaration]
     dest = localtime_r(timer, dest);
            ^~~~~~~~~~~

io/gets_s.c:144:32: error: implicit declaration of function 'strnlen'; did you mean 'strlen'? [-Werror=implicit-function-declaration]
         rsize_t len = (rsize_t)strnlen(dest, dmax);
                                ^~~~~~~
                                strlen

An other option would be to define AC_GNU_SOURCE in the configure.ac but
it seems that there is some handling of _GNU_SOURCE in
safeclib_private.h

Fixes:
 - http://autobuild.buildroot.net/results/31a4b647ec0dcd9f517f313ec6c7c8f56da1ee47

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  • Loading branch information
ffontaine authored and rurban committed Oct 29, 2019
1 parent 5d92be8 commit 94c7b76
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/extmem/memzero_s.c
Expand Up @@ -31,6 +31,8 @@
*------------------------------------------------------------------
*/

#define _GNU_SOURCE

#ifdef FOR_DOXYGEN
#include "safe_mem_lib.h"
#else
Expand Down
2 changes: 2 additions & 0 deletions src/io/gets_s.c
Expand Up @@ -29,6 +29,8 @@
*------------------------------------------------------------------
*/

#define _GNU_SOURCE

#ifdef FOR_DOXYGEN
#include "safe_lib.h"
#else
Expand Down
2 changes: 2 additions & 0 deletions src/os/asctime_s.c
Expand Up @@ -29,6 +29,8 @@
*------------------------------------------------------------------
*/

#define _GNU_SOURCE

#ifdef FOR_DOXYGEN
#include "safe_lib.h"
#else
Expand Down
2 changes: 2 additions & 0 deletions src/os/ctime_s.c
Expand Up @@ -29,6 +29,8 @@
*------------------------------------------------------------------
*/

#define _GNU_SOURCE

#ifdef FOR_DOXYGEN
#include "safe_lib.h"
#else
Expand Down
2 changes: 2 additions & 0 deletions src/os/gmtime_s.c
Expand Up @@ -29,6 +29,8 @@
*------------------------------------------------------------------
*/

#define _GNU_SOURCE

#ifdef FOR_DOXYGEN
#include "safe_lib.h"
#else
Expand Down
2 changes: 2 additions & 0 deletions src/os/localtime_s.c
Expand Up @@ -29,6 +29,8 @@
*------------------------------------------------------------------
*/

#define _GNU_SOURCE

#ifdef FOR_DOXYGEN
#include "safe_lib.h"
#else
Expand Down

0 comments on commit 94c7b76

Please sign in to comment.