1 | # Check for stdbool.h that conforms to C99.
|
---|
2 |
|
---|
3 | # Copyright (C) 2002-2003 Free Software Foundation, Inc.
|
---|
4 |
|
---|
5 | # This program is free software; you can redistribute it and/or modify
|
---|
6 | # it under the terms of the GNU General Public License as published by
|
---|
7 | # the Free Software Foundation; either version 2, or (at your option)
|
---|
8 | # any later version.
|
---|
9 |
|
---|
10 | # This program is distributed in the hope that it will be useful,
|
---|
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | # GNU General Public License for more details.
|
---|
14 |
|
---|
15 | # You should have received a copy of the GNU General Public License
|
---|
16 | # along with this program; if not, write to the Free Software
|
---|
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
---|
18 | # 02110-1301, USA.
|
---|
19 |
|
---|
20 | # This macro is only needed in autoconf <= 2.54. Newer versions of autoconf
|
---|
21 | # have this macro built-in.
|
---|
22 |
|
---|
23 | AC_DEFUN([AC_HEADER_STDBOOL],
|
---|
24 | [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
|
---|
25 | [ac_cv_header_stdbool_h],
|
---|
26 | [AC_TRY_COMPILE(
|
---|
27 | [
|
---|
28 | #include <stdbool.h>
|
---|
29 | #ifndef bool
|
---|
30 | "error: bool is not defined"
|
---|
31 | #endif
|
---|
32 | #ifndef false
|
---|
33 | "error: false is not defined"
|
---|
34 | #endif
|
---|
35 | #if false
|
---|
36 | "error: false is not 0"
|
---|
37 | #endif
|
---|
38 | #ifndef true
|
---|
39 | "error: false is not defined"
|
---|
40 | #endif
|
---|
41 | #if true != 1
|
---|
42 | "error: true is not 1"
|
---|
43 | #endif
|
---|
44 | #ifndef __bool_true_false_are_defined
|
---|
45 | "error: __bool_true_false_are_defined is not defined"
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | struct s { _Bool s: 1; _Bool t; } s;
|
---|
49 |
|
---|
50 | char a[true == 1 ? 1 : -1];
|
---|
51 | char b[false == 0 ? 1 : -1];
|
---|
52 | char c[__bool_true_false_are_defined == 1 ? 1 : -1];
|
---|
53 | char d[(bool) -0.5 == true ? 1 : -1];
|
---|
54 | bool e = &s;
|
---|
55 | char f[(_Bool) -0.0 == false ? 1 : -1];
|
---|
56 | char g[true];
|
---|
57 | char h[sizeof (_Bool)];
|
---|
58 | char i[sizeof s.t];
|
---|
59 | ],
|
---|
60 | [ return !a + !b + !c + !d + !e + !f + !g + !h + !i; ],
|
---|
61 | [ac_cv_header_stdbool_h=yes],
|
---|
62 | [ac_cv_header_stdbool_h=no])])
|
---|
63 | AC_CHECK_TYPES([_Bool])
|
---|
64 | if test $ac_cv_header_stdbool_h = yes; then
|
---|
65 | AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
|
---|
66 | fi])
|
---|