Skip to content

Commit

Permalink
meson: Set _XOPEN_SOURCE while checking strerror_r
Browse files Browse the repository at this point in the history
Otherwise it cannot detect either version of strerror_r, when compiled
with -Dc_std=c99.

Signed-off-by: Daiki Ueno <[email protected]>
  • Loading branch information
ueno committed Aug 28, 2024
1 parent 4a173c9 commit 5a79df4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,18 @@ foreach f : functions
endif
endforeach

if cc.has_function('strerror_r', prefix: '#include <string.h>')
strerror_r_code = '''
strerror_r_prefix = '''
#define _GNU_SOURCE
#ifndef __sun
#define _XOPEN_SOURCE 700
#endif
#include <errno.h>
#include <string.h>
'''

if cc.has_function('strerror_r', prefix: strerror_r_prefix)
strerror_r_code = strerror_r_prefix + '''
int main (void)
{
/* GNU strerror_r returns char *, XSI returns int */
Expand Down

0 comments on commit 5a79df4

Please sign in to comment.