summaryrefslogtreecommitdiffstats
path: root/gl/m4/c-bool.m4
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2023-02-10 10:43:20 (GMT)
committerGitHub <noreply@github.com>2023-02-10 10:43:20 (GMT)
commitc07206f2ccc2356aa74bc6813a94c2190017d44e (patch)
tree1677e5fdca5c3ce544e92c5484e16a0b68df1cc9 /gl/m4/c-bool.m4
parente92046f810658016b7c373677efefda3b21400e4 (diff)
parentd2fcf49ad4afc15f37d082d7bc96a808369ec2d4 (diff)
downloadmonitoring-plugins-c07206f.tar.gz
Merge pull request #1832 from RincewindsHat/gnulib_update_2023
Gnulib update 2023 and attendant fixes
Diffstat (limited to 'gl/m4/c-bool.m4')
-rw-r--r--gl/m4/c-bool.m451
1 files changed, 51 insertions, 0 deletions
diff --git a/gl/m4/c-bool.m4 b/gl/m4/c-bool.m4
new file mode 100644
index 0000000..f614371
--- /dev/null
+++ b/gl/m4/c-bool.m4
@@ -0,0 +1,51 @@
1# Check for bool that conforms to C2023.
2
3dnl Copyright 2022-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_C_BOOL],
9[
10 AC_CACHE_CHECK([for bool, true, false], [gl_cv_c_bool],
11 [AC_COMPILE_IFELSE(
12 [AC_LANG_SOURCE([[
13 #if true == false
14 #error "true == false"
15 #endif
16 extern bool b;
17 bool b = true == false;]])],
18 [gl_cv_c_bool=yes],
19 [gl_cv_c_bool=no])])
20 if test "$gl_cv_c_bool" = yes; then
21 AC_DEFINE([HAVE_C_BOOL], [1],
22 [Define to 1 if bool, true and false work as per C2023.])
23 fi
24
25 AC_CHECK_HEADERS_ONCE([stdbool.h])
26
27 dnl The "zz" puts this toward config.h's end, to avoid potential
28 dnl collisions with other definitions.
29 dnl If 'bool', 'true' and 'false' do not work, arrange for them to work.
30 dnl In C, this means including <stdbool.h> if it is not already included.
31 dnl However, if the preprocessor mistakenly treats 'true' as 0,
32 dnl define it to a bool expression equal to 1; this is needed in
33 dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older.
34 AH_VERBATIM([zzbool],
35[#ifndef HAVE_C_BOOL
36# if !defined __cplusplus && !defined __bool_true_false_are_defined
37# if HAVE_STDBOOL_H
38# include <stdbool.h>
39# else
40# if defined __SUNPRO_C
41# error "<stdbool.h> is not usable with this configuration. To make it usable, add -D_STDC_C99= to $CC."
42# else
43# error "<stdbool.h> does not exist on this platform. Use gnulib module 'stdbool-c99' instead of gnulib module 'stdbool'."
44# endif
45# endif
46# endif
47# if !true
48# define true (!false)
49# endif
50#endif])
51])