Annotation of embedaddon/libiconv/srcm4/stdbool.m4, revision 1.1.1.3
1.1 misho 1: # Check for stdbool.h that conforms to C99.
2:
1.1.1.3 ! misho 3: dnl Copyright (C) 2002-2006, 2009-2019 Free Software Foundation, Inc.
1.1 misho 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:
1.1.1.3 ! misho 8: #serial 7
1.1.1.2 misho 9:
1.1 misho 10: # Prepare for substituting <stdbool.h> if it is not supported.
11:
12: AC_DEFUN([AM_STDBOOL_H],
13: [
1.1.1.2 misho 14: AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
1.1 misho 15:
16: # Define two additional variables used in the Makefile substitution.
17:
18: if test "$ac_cv_header_stdbool_h" = yes; then
19: STDBOOL_H=''
20: else
21: STDBOOL_H='stdbool.h'
22: fi
23: AC_SUBST([STDBOOL_H])
1.1.1.2 misho 24: AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"])
1.1 misho 25:
26: if test "$ac_cv_type__Bool" = yes; then
27: HAVE__BOOL=1
28: else
29: HAVE__BOOL=0
30: fi
31: AC_SUBST([HAVE__BOOL])
32: ])
33:
34: # AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
35: AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
36:
1.1.1.2 misho 37: # This version of the macro is needed in autoconf <= 2.68.
1.1 misho 38:
1.1.1.2 misho 39: AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
1.1 misho 40: [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
41: [ac_cv_header_stdbool_h],
1.1.1.2 misho 42: [AC_COMPILE_IFELSE(
43: [AC_LANG_PROGRAM(
44: [[
45: #include <stdbool.h>
1.1.1.3 ! misho 46:
! 47: #ifdef __cplusplus
! 48: typedef bool Bool;
! 49: #else
! 50: typedef _Bool Bool;
! 51: #ifndef bool
! 52: "error: bool is not defined"
! 53: #endif
! 54: #ifndef false
! 55: "error: false is not defined"
! 56: #endif
! 57: #if false
! 58: "error: false is not 0"
! 59: #endif
! 60: #ifndef true
! 61: "error: true is not defined"
! 62: #endif
! 63: #if true != 1
! 64: "error: true is not 1"
! 65: #endif
1.1.1.2 misho 66: #endif
1.1.1.3 ! misho 67:
1.1.1.2 misho 68: #ifndef __bool_true_false_are_defined
69: "error: __bool_true_false_are_defined is not defined"
70: #endif
71:
1.1.1.3 ! misho 72: struct s { Bool s: 1; Bool t; bool u: 1; bool v; } s;
1.1.1.2 misho 73:
74: char a[true == 1 ? 1 : -1];
75: char b[false == 0 ? 1 : -1];
76: char c[__bool_true_false_are_defined == 1 ? 1 : -1];
77: char d[(bool) 0.5 == true ? 1 : -1];
78: /* See body of main program for 'e'. */
1.1.1.3 ! misho 79: char f[(Bool) 0.0 == false ? 1 : -1];
1.1.1.2 misho 80: char g[true];
1.1.1.3 ! misho 81: char h[sizeof (Bool)];
1.1.1.2 misho 82: char i[sizeof s.t];
83: enum { j = false, k = true, l = false * true, m = true * 256 };
84: /* The following fails for
85: HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
1.1.1.3 ! misho 86: Bool n[m];
1.1.1.2 misho 87: char o[sizeof n == m * sizeof n[0] ? 1 : -1];
1.1.1.3 ! misho 88: char p[-1 - (Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
1.1.1.2 misho 89: /* Catch a bug in an HP-UX C compiler. See
1.1.1.3 ! misho 90: https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
! 91: https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html
1.1.1.2 misho 92: */
1.1.1.3 ! misho 93: Bool q = true;
! 94: Bool *pq = &q;
! 95: bool *qq = &q;
1.1.1.2 misho 96: ]],
97: [[
98: bool e = &s;
1.1.1.3 ! misho 99: *pq |= q; *pq |= ! q;
! 100: *qq |= q; *qq |= ! q;
1.1.1.2 misho 101: /* Refer to every declared value, to avoid compiler optimizations. */
102: return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
1.1.1.3 ! misho 103: + !m + !n + !o + !p + !q + !pq + !qq);
1.1.1.2 misho 104: ]])],
105: [ac_cv_header_stdbool_h=yes],
106: [ac_cv_header_stdbool_h=no])])
1.1 misho 107: AC_CHECK_TYPES([_Bool])
1.1.1.2 misho 108: ])
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>