Mercurial > hg > octave-shane > gnulib-hg
annotate m4/stdbool.m4 @ 6345:5abccb682fc6
* stdbool.m4 (AC_HEADER_STDBOOL): Check that bool
promotes to int, not unsigned int, to catch the AIX 5.3
compiler bug.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 06 Oct 2005 16:44:39 +0000 |
parents | adff74659d81 |
children | 7398c10d65f5 |
rev | line source |
---|---|
3889
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
1 # Check for stdbool.h that conforms to C99. |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
2 |
6345
5abccb682fc6
* stdbool.m4 (AC_HEADER_STDBOOL): Check that bool
Paul Eggert <eggert@cs.ucla.edu>
parents:
5585
diff
changeset
|
3 dnl Copyright (C) 2002-2005 Free Software Foundation, Inc. |
5585
adff74659d81
Use an all-permissive copyright notice, recommended by RMS.
Bruno Haible <bruno@clisp.org>
parents:
5075
diff
changeset
|
4 dnl This file is free software; the Free Software Foundation |
adff74659d81
Use an all-permissive copyright notice, recommended by RMS.
Bruno Haible <bruno@clisp.org>
parents:
5075
diff
changeset
|
5 dnl gives unlimited permission to copy and/or distribute it, |
adff74659d81
Use an all-permissive copyright notice, recommended by RMS.
Bruno Haible <bruno@clisp.org>
parents:
5075
diff
changeset
|
6 dnl with or without modifications, as long as this notice is preserved. |
3889
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
7 |
4151
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
8 # Prepare for substituting <stdbool.h> if it is not supported. |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
9 |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
10 AC_DEFUN([AM_STDBOOL_H], |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
11 [ |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
12 AC_REQUIRE([AC_HEADER_STDBOOL]) |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
13 |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
14 # Define two additional variables used in the Makefile substitution. |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
15 |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
16 if test "$ac_cv_header_stdbool_h" = yes; then |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
17 STDBOOL_H='' |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
18 else |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
19 STDBOOL_H='stdbool.h' |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
20 fi |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
21 AC_SUBST([STDBOOL_H]) |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
22 |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
23 if test "$ac_cv_type__Bool" = yes; then |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
24 HAVE__BOOL=1 |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
25 else |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
26 HAVE__BOOL=0 |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
27 fi |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
28 AC_SUBST([HAVE__BOOL]) |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
29 ]) |
3a0c83552f0e
Make it possible to #include <stdbool.h> without any #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
4108
diff
changeset
|
30 |
5075
da468be96043
Detect _Bool bug in HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003].
Paul Eggert <eggert@cs.ucla.edu>
parents:
4151
diff
changeset
|
31 # This macro is only needed in autoconf <= 2.59. Newer versions of autoconf |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3889
diff
changeset
|
32 # have this macro built-in. |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3889
diff
changeset
|
33 |
3889
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
34 AC_DEFUN([AC_HEADER_STDBOOL], |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
35 [AC_CACHE_CHECK([for stdbool.h that conforms to C99], |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
36 [ac_cv_header_stdbool_h], |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
37 [AC_TRY_COMPILE( |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
38 [ |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
39 #include <stdbool.h> |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
40 #ifndef bool |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
41 "error: bool is not defined" |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
42 #endif |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
43 #ifndef false |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
44 "error: false is not defined" |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
45 #endif |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
46 #if false |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
47 "error: false is not 0" |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
48 #endif |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
49 #ifndef true |
5075
da468be96043
Detect _Bool bug in HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003].
Paul Eggert <eggert@cs.ucla.edu>
parents:
4151
diff
changeset
|
50 "error: true is not defined" |
3889
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
51 #endif |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
52 #if true != 1 |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
53 "error: true is not 1" |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
54 #endif |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
55 #ifndef __bool_true_false_are_defined |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
56 "error: __bool_true_false_are_defined is not defined" |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
57 #endif |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
58 |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
59 struct s { _Bool s: 1; _Bool t; } s; |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
60 |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
61 char a[true == 1 ? 1 : -1]; |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
62 char b[false == 0 ? 1 : -1]; |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
63 char c[__bool_true_false_are_defined == 1 ? 1 : -1]; |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
64 char d[(bool) -0.5 == true ? 1 : -1]; |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
65 bool e = &s; |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
66 char f[(_Bool) -0.0 == false ? 1 : -1]; |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
67 char g[true]; |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
68 char h[sizeof (_Bool)]; |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
69 char i[sizeof s.t]; |
5075
da468be96043
Detect _Bool bug in HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003].
Paul Eggert <eggert@cs.ucla.edu>
parents:
4151
diff
changeset
|
70 enum { j = false, k = true, l = false * true, m = true * 256 }; |
da468be96043
Detect _Bool bug in HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003].
Paul Eggert <eggert@cs.ucla.edu>
parents:
4151
diff
changeset
|
71 _Bool n[m]; |
da468be96043
Detect _Bool bug in HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003].
Paul Eggert <eggert@cs.ucla.edu>
parents:
4151
diff
changeset
|
72 char o[sizeof n == m * sizeof n[0] ? 1 : -1]; |
6345
5abccb682fc6
* stdbool.m4 (AC_HEADER_STDBOOL): Check that bool
Paul Eggert <eggert@cs.ucla.edu>
parents:
5585
diff
changeset
|
73 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; |
3889
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
74 ], |
5075
da468be96043
Detect _Bool bug in HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003].
Paul Eggert <eggert@cs.ucla.edu>
parents:
4151
diff
changeset
|
75 [ |
da468be96043
Detect _Bool bug in HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003].
Paul Eggert <eggert@cs.ucla.edu>
parents:
4151
diff
changeset
|
76 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k + !l |
6345
5abccb682fc6
* stdbool.m4 (AC_HEADER_STDBOOL): Check that bool
Paul Eggert <eggert@cs.ucla.edu>
parents:
5585
diff
changeset
|
77 + !m + !n + !o + !p); |
5075
da468be96043
Detect _Bool bug in HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003].
Paul Eggert <eggert@cs.ucla.edu>
parents:
4151
diff
changeset
|
78 ], |
3889
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
79 [ac_cv_header_stdbool_h=yes], |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
80 [ac_cv_header_stdbool_h=no])]) |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3889
diff
changeset
|
81 AC_CHECK_TYPES([_Bool]) |
3889
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
82 if test $ac_cv_header_stdbool_h = yes; then |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
83 AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.]) |
c6cde8cafff6
New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
84 fi]) |