1# Check for stdbool.h that conforms to C99. 2 3# Copyright (C) 2002 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., 59 Temple Place - Suite 330, Boston, MA 18# 02111-1307, USA. 19 20AC_DEFUN([AC_HEADER_STDBOOL], 21 [AC_CACHE_CHECK([for stdbool.h that conforms to C99], 22 [ac_cv_header_stdbool_h], 23 [AC_TRY_COMPILE( 24 [ 25 #include <stdbool.h> 26 #ifndef bool 27 "error: bool is not defined" 28 #endif 29 #ifndef false 30 "error: false is not defined" 31 #endif 32 #ifndef true 33 "error: false is not defined" 34 #endif 35 #ifndef __bool_true_false_are_defined 36 "error: __bool_true_false_are_defined is not defined" 37 #endif 38 39 struct s { _Bool s: 1; _Bool t; } s; 40 41 char a[true == 1 ? 1 : -1]; 42 char b[false == 0 ? 1 : -1]; 43 char c[__bool_true_false_are_defined == 1 ? 1 : -1]; 44 char d[(bool) -0.5 == true ? 1 : -1]; 45 char e[(bool) &s == true ? 1 : -1]; 46 char f[(_Bool) -0.0 == false ? 1 : -1]; 47 char g[true]; 48 char h[sizeof (_Bool)]; 49 char i[sizeof s.t]; 50 ], 51 [ return !a + !b + !c + !d + !e + !f + !g + !h + !i; ], 52 [ac_cv_header_stdbool_h=yes], 53 [ac_cv_header_stdbool_h=no])]) 54 if test $ac_cv_header_stdbool_h = yes; then 55 AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.]) 56 fi]) 57