Eric Blake wrote: > Rather than hard-code the check based on platform-specific defines, it > would be more in the autoconf spirit to instead write a probe whether > <stdlib.h> declares alloca(), and if so, define a witness macro.
Unfortunately, the code is also used in bison/data/yacc.c [1], that is, in the skeleton that bison uses for a certain class of parsers. Therefore we have to continue to find a code template that does not use information from a configure script. And the code is also in the Autoconf manual. Thomas Klausner wrote: > Do not fall through to the implicit prototype as it conflicts with > stdlib.h. More details: - The declaration in the code snippet from Autoconf uses 'char *alloca();'. - On FreeBSD, the declaration of alloca is only conditionally visible, namely if __BSD_VISIBLE. Its return type is 'void *', and the declaration is present since 1994. - On OpenBSD, the declaration of alloca is only conditionally visible, namely if __BSD_VISIBLE since 2005; another condition was used before. Its return type is 'void *', and the declaration is present since 1995. - On NetBSD, the declaration of alloca is only conditionally visible, namely if _NETBSD_SOURCE. Its return type is usually 'void *'. - On all three systems, the double-inclusion guard of <stdlib.h> is _STDLIB_H_. So, I don't understand how you see a "conflict". The test code in AC_FUNC_ALLOCA does not include <stdlib.h>, only <stddef.h>; how can that clash? And after configure has run, the Autoconf manual recommends to declare alloca as follows: #ifdef HAVE_ALLOCA_H # include <alloca.h> #elif defined __GNUC__ # define alloca __builtin_alloca #elif defined _AIX # define alloca __alloca #elif defined _MSC_VER # include <malloc.h> # define alloca _alloca #else # include <stddef.h> # ifdef __cplusplus extern "C" # endif void *alloca (size_t); #endif This also cannot conflict with <stdlib.h>. But seeing that no platform nowadays assumes a return type of 'char *' for alloca, it would be possible to change the prototype anyway: 2010-08-05 Bruno Haible <br...@clisp.org> Modernize AC_FUNC_ALLOCA. * lib/autoconf/functions.m4 (AC_FUNC_ALLOCA): Assume that alloca's return type is 'void *', not 'char *'. --- autoconf/lib/autoconf/functions.m4.orig Thu Aug 5 13:19:01 2010 +++ autoconf/lib/autoconf/functions.m4 Thu Aug 5 13:16:25 2010 @@ -388,7 +388,7 @@ #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); +void *alloca (); # endif # endif # endif Bruno [1] http://git.savannah.gnu.org/gitweb/?p=bison.git;a=blob;f=data/yacc.c;hb=HEAD