`size_t' which are often used too.
Fix a bug which prevents recognition of `bool' and `char'.
(_AC_CHECK_TYPE_MAYBE_TYPE_P): New macro.
(AC_CHECK_TYPE): Use it.
+2000-07-24 Akim Demaille <akim@epita.fr>
+
+ * acgeneral.m4 (_AC_CHECK_TYPE_BUILTIN_P): Add `off_t' and
+ `size_t' which are often used too.
+ Fix a bug which prevents recognition of `bool' and `char'.
+ (_AC_CHECK_TYPE_MAYBE_TYPE_P): New macro.
+ (AC_CHECK_TYPE): Use it.
+
2000-07-19 Peter Eisentraut <peter_e@gmx.net>
* Makefile.am: Remove INSTALL.txt by maintainer-clean target.
])# _AC_CHECK_TYPE_OLD
-# _AC_CHECK_TYPE_BUILTIN_P(STRING)
-# --------------------------------
+# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P(STRING)
+# -----------------------------------------
# Return `1' if STRING seems to be a builtin C/C++ type, i.e., if it
# starts with `_Bool', `bool', `char', `double', `float', `int',
# `long', `short', `signed', or `unsigned' followed by characters
# that are defining types.
-define([_AC_CHECK_TYPE_BUILTIN_P],
-[ifelse(regexp([$1], [^\(_Bool\|bool|\char\|double\|float\|int\|long\|short\|\(un\)?signed\)\([_a-zA-Z0-9() *]\|\[\|\]\)*$]),
+# Because many people have used `off_t' and `size_t' too, they are added
+# for better common-useward backward compatibility.
+define([_AC_CHECK_TYPE_REPLACEMENT_TYPE_P],
+[ifelse(regexp([$1],
+ [^\(_Bool\|bool\|char\|double\|float\|int\|long\|short\|\(un\)?signed\|size_t\|off_t\)\([_a-zA-Z0-9() *]\|\[\|\]\)*$]),
+ 0, 1, 0)dnl
+])# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P
+
+
+# _AC_CHECK_TYPE_MAYBE_TYPE_P(STRING)
+# -----------------------------------
+# Return `1' if STRING looks like a C/C++ type.
+define([_AC_CHECK_TYPE_MAYBE_TYPE_P],
+[ifelse(regexp([$1], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$]),
0, 1, 0)dnl
-])# _AC_CHECK_TYPE_BUILTIN_P
+])# _AC_CHECK_TYPE_MAYBE_TYPE_P
# AC_CHECK_TYPE(TYPE, DEFAULT)
# -------------------------------------------------------
#
# Dispatch respectively to _AC_CHECK_TYPE_OLD or _AC_CHECK_TYPE_NEW.
-# 1. More than two arguments => NEW
-# 2. $2 seems to be builtin type => OLD
-# 3. $2 seems to be a type => NEW plus a warning
-# 4. default => NEW
+# 1. More than two arguments => NEW
+# 2. $2 seems to be replacement type => OLD
+# See _AC_CHECK_TYPE_REPLACEMENT_TYPE_P for `replacement type'.
+# 3. $2 seems to be a type => NEW plus a warning
+# 4. default => NEW
AC_DEFUN([AC_CHECK_TYPE],
-[ifelse($#, 3, [_AC_CHECK_TYPE_NEW($@)],
- $#, 4, [_AC_CHECK_TYPE_NEW($@)],
- _AC_CHECK_TYPE_BUILTIN_P([$2]), 1, [_AC_CHECK_TYPE_OLD($@)],
- regexp([$2], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), 0, [m4_warn([$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)],
+[ifelse($#, 3,
+ [_AC_CHECK_TYPE_NEW($@)],
+ $#, 4,
+ [_AC_CHECK_TYPE_NEW($@)],
+ _AC_CHECK_TYPE_REPLACEMENT_TYPE_P([$2]), 1,
+ [_AC_CHECK_TYPE_OLD($@)],
+ _AC_CHECK_TYPE_MAYBE_TYPE_P([$2]), 1,
+ [m4_warn([$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)],
[_AC_CHECK_TYPE_NEW($@)])[]dnl
])# AC_CHECK_TYPE
Autoconf, up to 2.13, used to provide to another version of
@code{AC_CHECK_TYPE}, broken by design. In order to keep backward
compatibility, a simple heuristics, quite safe but not totally, is
-implemented. In case of doubt, the reader is strongly encouraged to
-read the documentation of the former @code{AC_CHECK_TYPE}, see
-@ref{Obsolete Macros}.
+implemented. In case of doubt, read the documentation of the former
+@code{AC_CHECK_TYPE}, see @ref{Obsolete Macros}.
@node Compilers and Preprocessors, C Compiler Characteristics, Types, Existing Tests
@defmac AC_CHECK_TYPE (@var{type}, @var{default})
@maindex CHECK_TYPE
-Autoconf, up to 2.13, used to provide to this version of
-@code{AC_CHECK_TYPE}, broken by design. First, although it is a member
-of the @code{CHECK} clan, singular sub-family, it does more than just
-checking. Second, missing types are not typedef'd, they are defined,
-which can lead to incompatible code in the case of pointer types.
+Autoconf, up to 2.13, used to provide this version of
+@code{AC_CHECK_TYPE} deprecated because of it flaws. Firstly, although
+it is a member of the @code{CHECK} clan, singular sub-family, it does
+more than just checking. Second, missing types are not
+@code{typedef}'d, they are @code{#define}'d, which can lead to
+incompatible code in the case of pointer types.
This use of @code{AC_CHECK_TYPE} is obsolete and discouraged, see
@ref{Generic Types}, for the description of the current macro.
If the type @var{type} is not defined, define it to be the C (or C++)
builtin type @var{default}; e.g., @samp{short} or @samp{unsigned}.
-This macro is equivalent to
+This macro is equivalent to:
+
@example
AC_CHECK_TYPE([@var{type}],
[AC_DEFINE([@var{type}], [@var{default}],
[Define to `@var{default}' if <sys/types.h>
does not define.])])
@end example
+
In order to keep backward compatibility, the two versions of
@code{AC_CHECK_TYPE} are implemented, selected by a simple heuristics:
-@itemize @bullet
-@item
-if there are three or four arguments, the modern version is used;
+@enumerate
@item
-if the second argument is a C or C++ @strong{builtin} type, then the
-obsolete version is used;
+If there are three or four arguments, the modern version is used.
@item
-if the second argument is spelled with the alphabet of valid C and C++
-types, the user is warned and the modern version is used;
+If the second argument is a C or C++ @emph{builtin} type, then the
+obsolete version is used. Because many people have used @samp{off_t}
+and @samp{size_t} as replacement types, they are recognized too.
@item
-otherwise, the modern version is used.
-@end itemize
+If the second argument is spelled with the alphabet of valid C and C++
+types, the user is warned and the modern version is used.
-@noindent
-In particular, the following code, which was invalid but functional:
-
-@example
-AC_CHECK_TYPE(loff_t, off_t)
-@end example
+@item
+Otherwise, the modern version is used.
+@end enumerate
@noindent
-will be improperly branched to the modern implementation. You are
-encouraged either to use a valid builtin type, or to use the equivalent
-modern code (see above), or better yet, to use @code{AC_CHECK_TYPES}
-together with
+You are encouraged either to use a valid builtin type, or to use the
+equivalent modern code (see above), or better yet, to use
+@code{AC_CHECK_TYPES} together with
@example
#if !HAVE_LOFF_T
])# _AC_CHECK_TYPE_OLD
-# _AC_CHECK_TYPE_BUILTIN_P(STRING)
-# --------------------------------
+# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P(STRING)
+# -----------------------------------------
# Return `1' if STRING seems to be a builtin C/C++ type, i.e., if it
# starts with `_Bool', `bool', `char', `double', `float', `int',
# `long', `short', `signed', or `unsigned' followed by characters
# that are defining types.
-define([_AC_CHECK_TYPE_BUILTIN_P],
-[ifelse(regexp([$1], [^\(_Bool\|bool|\char\|double\|float\|int\|long\|short\|\(un\)?signed\)\([_a-zA-Z0-9() *]\|\[\|\]\)*$]),
+# Because many people have used `off_t' and `size_t' too, they are added
+# for better common-useward backward compatibility.
+define([_AC_CHECK_TYPE_REPLACEMENT_TYPE_P],
+[ifelse(regexp([$1],
+ [^\(_Bool\|bool\|char\|double\|float\|int\|long\|short\|\(un\)?signed\|size_t\|off_t\)\([_a-zA-Z0-9() *]\|\[\|\]\)*$]),
+ 0, 1, 0)dnl
+])# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P
+
+
+# _AC_CHECK_TYPE_MAYBE_TYPE_P(STRING)
+# -----------------------------------
+# Return `1' if STRING looks like a C/C++ type.
+define([_AC_CHECK_TYPE_MAYBE_TYPE_P],
+[ifelse(regexp([$1], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$]),
0, 1, 0)dnl
-])# _AC_CHECK_TYPE_BUILTIN_P
+])# _AC_CHECK_TYPE_MAYBE_TYPE_P
# AC_CHECK_TYPE(TYPE, DEFAULT)
# -------------------------------------------------------
#
# Dispatch respectively to _AC_CHECK_TYPE_OLD or _AC_CHECK_TYPE_NEW.
-# 1. More than two arguments => NEW
-# 2. $2 seems to be builtin type => OLD
-# 3. $2 seems to be a type => NEW plus a warning
-# 4. default => NEW
+# 1. More than two arguments => NEW
+# 2. $2 seems to be replacement type => OLD
+# See _AC_CHECK_TYPE_REPLACEMENT_TYPE_P for `replacement type'.
+# 3. $2 seems to be a type => NEW plus a warning
+# 4. default => NEW
AC_DEFUN([AC_CHECK_TYPE],
-[ifelse($#, 3, [_AC_CHECK_TYPE_NEW($@)],
- $#, 4, [_AC_CHECK_TYPE_NEW($@)],
- _AC_CHECK_TYPE_BUILTIN_P([$2]), 1, [_AC_CHECK_TYPE_OLD($@)],
- regexp([$2], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), 0, [m4_warn([$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)],
+[ifelse($#, 3,
+ [_AC_CHECK_TYPE_NEW($@)],
+ $#, 4,
+ [_AC_CHECK_TYPE_NEW($@)],
+ _AC_CHECK_TYPE_REPLACEMENT_TYPE_P([$2]), 1,
+ [_AC_CHECK_TYPE_OLD($@)],
+ _AC_CHECK_TYPE_MAYBE_TYPE_P([$2]), 1,
+ [m4_warn([$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)],
[_AC_CHECK_TYPE_NEW($@)])[]dnl
])# AC_CHECK_TYPE