Skip to content

Commit

Permalink
meson: Set _GNU_SOURCE when checking <locale.h> type and functions
Browse files Browse the repository at this point in the history
Otherwise neither locale_t, newlocale, nor strerror_l is detected
under -Dc_std=c99.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
  • Loading branch information
ueno committed Aug 28, 2024
1 parent 0992915 commit e6c6972
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,20 @@ if host_system != 'windows'

if cc.has_header('locale.h')
conf.set('HAVE_LOCALE_H', 1)
if cc.has_type('locale_t', prefix: '#include <locale.h>')
locale_prefix = '''
#define _GNU_SOURCE
#include <locale.h>
'''
if cc.has_type('locale_t', prefix: locale_prefix)
conf.set('HAVE_LOCALE_T', 1)
if cc.has_function('newlocale', prefix: '#include <locale.h>')
if cc.has_function('newlocale', prefix: locale_prefix)
conf.set('HAVE_NEWLOCALE', 1)
endif
if cc.has_function('strerror_l', prefix: '#include <string.h>')
strerror_l_prefix = '''
#define _GNU_SOURCE
#include <string.h>
'''
if cc.has_function('strerror_l', prefix: strerror_l_prefix)
conf.set('HAVE_STRERROR_L', 1)
endif
endif
Expand Down

0 comments on commit e6c6972

Please sign in to comment.