Skip to content

Commit e6c6972

Browse files
committed
meson: Set _GNU_SOURCE when checking <locale.h> type and functions
Otherwise neither locale_t, newlocale, nor strerror_l is detected under -Dc_std=c99. Signed-off-by: Daiki Ueno <ueno@gnu.org>
1 parent 0992915 commit e6c6972

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

meson.build

+11-3
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,20 @@ if host_system != 'windows'
170170

171171
if cc.has_header('locale.h')
172172
conf.set('HAVE_LOCALE_H', 1)
173-
if cc.has_type('locale_t', prefix: '#include <locale.h>')
173+
locale_prefix = '''
174+
#define _GNU_SOURCE
175+
#include <locale.h>
176+
'''
177+
if cc.has_type('locale_t', prefix: locale_prefix)
174178
conf.set('HAVE_LOCALE_T', 1)
175-
if cc.has_function('newlocale', prefix: '#include <locale.h>')
179+
if cc.has_function('newlocale', prefix: locale_prefix)
176180
conf.set('HAVE_NEWLOCALE', 1)
177181
endif
178-
if cc.has_function('strerror_l', prefix: '#include <string.h>')
182+
strerror_l_prefix = '''
183+
#define _GNU_SOURCE
184+
#include <string.h>
185+
'''
186+
if cc.has_function('strerror_l', prefix: strerror_l_prefix)
179187
conf.set('HAVE_STRERROR_L', 1)
180188
endif
181189
endif

0 commit comments

Comments
 (0)