diff options
author | Kristian Schuster <116557017+KriSchu@users.noreply.github.com> | 2023-02-19 23:49:18 +0100 |
---|---|---|
committer | Kristian Schuster <116557017+KriSchu@users.noreply.github.com> | 2023-02-19 23:49:18 +0100 |
commit | a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7 (patch) | |
tree | 8effe94c57b2f9796ba36090b07551baa8f1e1cb /gl/m4/c-bool.m4 | |
parent | ca3d59cd6918c9e2739e783b721d4c1122640fd3 (diff) | |
parent | c07206f2ccc2356aa74bc6813a94c2190017d44e (diff) | |
download | monitoring-plugins-a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7.tar.gz |
Merge remote-tracking branch 'origin/master' into feature_check_disk_add_ignore_missing_option
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 00000000..f614371b --- /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 | ]) | ||