Permalink
Browse files

Include stdlib.h when checking for mkostemp

On most platforms `mkostemp()` is declared in stdlib.h but on macOS it
is in unistd.h so include both headers in the feature test.
  • Loading branch information...
krader1961 committed Oct 11, 2018
1 parent 4384f64 commit 9b8b0b8273fa6c8b8355a49130f9d28ac939b5ec
Showing with 3 additions and 2 deletions.
  1. +2 −1 features/meson.build
  2. +1 −1 src/lib/libast/misc/fallbacks.c
View
@@ -64,7 +64,8 @@ if not cc.has_function('isnanl', prefix: '#include <math.h>', args: feature_test
endif
feature_data.set10('_lib_mkostemp',
cc.has_function('mkostemp', prefix: '#include <unistd.h>', args: feature_test_args))
cc.has_function('mkostemp', prefix: '\n'.join(['#include <stdlib.h>', '#include <unistd.h>']),
args: feature_test_args))
feature_data.set10('_lib_strlcat',
cc.has_function('strlcat', prefix: '#include <string.h>', args: feature_test_args))
feature_data.set10('_lib_utimensat',
@@ -24,7 +24,7 @@ void do_not_use_this_fallback() {
#if !_lib_mkostemp
// This is a fallback in case the system doesn't provide it.
static_fn int mkostemp(char *template, int oflags) {
int mkostemp(char *template, int oflags) {
for (int i = 10; i; i--) {
#ifndef __clang_analyzer__
// cppcheck-suppress mktempCalled

0 comments on commit 9b8b0b8

Please sign in to comment.