|
version 1.1.1.2, 2012/05/29 09:29:44
|
version 1.1.1.3, 2021/03/17 13:38:46
|
|
Line 1
|
Line 1
|
| # Check for stdbool.h that conforms to C99. |
# Check for stdbool.h that conforms to C99. |
| |
|
| dnl Copyright (C) 2002-2006, 2009-2011 Free Software Foundation, Inc. | dnl Copyright (C) 2002-2006, 2009-2019 Free Software Foundation, Inc. |
| dnl This file is free software; the Free Software Foundation |
dnl This file is free software; the Free Software Foundation |
| dnl gives unlimited permission to copy and/or distribute it, |
dnl gives unlimited permission to copy and/or distribute it, |
| dnl with or without modifications, as long as this notice is preserved. |
dnl with or without modifications, as long as this notice is preserved. |
| |
|
| #serial 5 | #serial 7 |
| |
|
| # Prepare for substituting <stdbool.h> if it is not supported. |
# Prepare for substituting <stdbool.h> if it is not supported. |
| |
|
|
Line 43 AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
|
Line 43 AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
|
| [AC_LANG_PROGRAM( |
[AC_LANG_PROGRAM( |
| [[ |
[[ |
| #include <stdbool.h> |
#include <stdbool.h> |
| #ifndef bool | |
| "error: bool is not defined" | #ifdef __cplusplus |
| | typedef bool Bool; |
| | #else |
| | typedef _Bool Bool; |
| | #ifndef bool |
| | "error: bool is not defined" |
| | #endif |
| | #ifndef false |
| | "error: false is not defined" |
| | #endif |
| | #if false |
| | "error: false is not 0" |
| | #endif |
| | #ifndef true |
| | "error: true is not defined" |
| | #endif |
| | #if true != 1 |
| | "error: true is not 1" |
| | #endif |
| #endif |
#endif |
| #ifndef false | |
| "error: false is not defined" | |
| #endif | |
| #if false | |
| "error: false is not 0" | |
| #endif | |
| #ifndef true | |
| "error: true is not defined" | |
| #endif | |
| #if true != 1 | |
| "error: true is not 1" | |
| #endif | |
| #ifndef __bool_true_false_are_defined |
#ifndef __bool_true_false_are_defined |
| "error: __bool_true_false_are_defined is not defined" |
"error: __bool_true_false_are_defined is not defined" |
| #endif |
#endif |
| |
|
| struct s { _Bool s: 1; _Bool t; } s; | struct s { Bool s: 1; Bool t; bool u: 1; bool v; } s; |
| |
|
| char a[true == 1 ? 1 : -1]; |
char a[true == 1 ? 1 : -1]; |
| char b[false == 0 ? 1 : -1]; |
char b[false == 0 ? 1 : -1]; |
| char c[__bool_true_false_are_defined == 1 ? 1 : -1]; |
char c[__bool_true_false_are_defined == 1 ? 1 : -1]; |
| char d[(bool) 0.5 == true ? 1 : -1]; |
char d[(bool) 0.5 == true ? 1 : -1]; |
| /* See body of main program for 'e'. */ |
/* See body of main program for 'e'. */ |
| char f[(_Bool) 0.0 == false ? 1 : -1]; | char f[(Bool) 0.0 == false ? 1 : -1]; |
| char g[true]; |
char g[true]; |
| char h[sizeof (_Bool)]; | char h[sizeof (Bool)]; |
| char i[sizeof s.t]; |
char i[sizeof s.t]; |
| enum { j = false, k = true, l = false * true, m = true * 256 }; |
enum { j = false, k = true, l = false * true, m = true * 256 }; |
| /* The following fails for |
/* The following fails for |
| HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ |
HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ |
| _Bool n[m]; | Bool n[m]; |
| char o[sizeof n == m * sizeof n[0] ? 1 : -1]; |
char o[sizeof n == m * sizeof n[0] ? 1 : -1]; |
| char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; | char p[-1 - (Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; |
| /* Catch a bug in an HP-UX C compiler. See |
/* Catch a bug in an HP-UX C compiler. See |
| http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html | https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html |
| http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html | https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html |
| */ |
*/ |
| _Bool q = true; | Bool q = true; |
| _Bool *pq = &q; | Bool *pq = &q; |
| | bool *qq = &q; |
| ]], |
]], |
| [[ |
[[ |
| bool e = &s; |
bool e = &s; |
| *pq |= q; | *pq |= q; *pq |= ! q; |
| *pq |= ! q; | *qq |= q; *qq |= ! q; |
| /* Refer to every declared value, to avoid compiler optimizations. */ |
/* Refer to every declared value, to avoid compiler optimizations. */ |
| return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l |
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l |
| + !m + !n + !o + !p + !q + !pq); | + !m + !n + !o + !p + !q + !pq + !qq); |
| ]])], |
]])], |
| [ac_cv_header_stdbool_h=yes], |
[ac_cv_header_stdbool_h=yes], |
| [ac_cv_header_stdbool_h=no])]) |
[ac_cv_header_stdbool_h=no])]) |