diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-31 13:46:01 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-31 13:46:01 (GMT) |
commit | e8bd88d1fcded01ccd066572eeaae1b507989cb3 (patch) | |
tree | c8e7be6c07c6f635f6e803e6a6ba9e7a95fee7c0 /gl/m4/c-bool.m4 | |
parent | 2ad962c13473607ca0d974bfaa516a0ed53ec73d (diff) | |
download | monitoring-plugins-e8bd88d1fcded01ccd066572eeaae1b507989cb3.tar.gz |
Sync with the latest Gnulib code 668c0b8ffa
Diffstat (limited to 'gl/m4/c-bool.m4')
-rw-r--r-- | gl/m4/c-bool.m4 | 51 |
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 | |||
3 | dnl Copyright 2022-2023 Free Software Foundation, Inc. | ||
4 | dnl This file is free software; the Free Software Foundation | ||
5 | dnl gives unlimited permission to copy and/or distribute it, | ||
6 | dnl with or without modifications, as long as this notice is preserved. | ||
7 | |||
8 | AC_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 | ]) | ||