From 89004005168e7af583860225e8cc3cf08ac35b41 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 14 Apr 2019 03:45:04 +0100 Subject: [PATCH] build: check if std-predef.h exists Fix build on FreeBSD / non-glibc systems Signed-off-by: Yuxuan Shui --- meson.build | 4 ++++ src/compiler.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/meson.build b/meson.build index ff25fab9..f8d5c841 100644 --- a/meson.build +++ b/meson.build @@ -49,6 +49,10 @@ endif add_global_arguments('-D_GNU_SOURCE', language: 'c') +if cc.has_header('stdc-predef.h') + add_global_arguments('-DHAS_STDC_PREDEF_H', language: 'c') +endif + warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow', 'no-type-limits', 'implicit-fallthrough', 'no-unknown-warning-option', 'no-missing-braces', 'conversion' ] foreach w : warns diff --git a/src/compiler.h b/src/compiler.h index e26736fb..153853bf 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -2,7 +2,9 @@ // Copyright (c) 2018 Yuxuan Shui #pragma once +#ifdef HAS_STDC_PREDEF_H #include +#endif #define auto __auto_type #define likely(x) __builtin_expect(!!(x), 1)