[Gllug] continuing the autoconf saga... AC_FUNC_MALLOC

Nix nix at esperi.demon.co.uk
Sat Jun 29 16:36:23 UTC 2002


On Sat, 29 Jun 2002, Stig Brautaset uttered the following:
> The documentation for the AC_FUNC_MALLOC this:
> 
>  - Macro: AC_FUNC_MALLOC
[snip]
> I've checked, on my platform malloc() does indeed return a valid
> pointer. The program to test this:
> 
> #include <stdlib.h>
> #include <stdio.h>
> 
> int main(void)
> {
> 	char *s;
> 	s = malloc(0);
> 	if (s) puts("malloc returned pointer");
> 	else puts("malloc returned NULL");
> 	return 0;
> }

OK. Same results here (not surprising, as glibc malloc always has these
semantics).

> Regardless, the HAVE_MALLOC persists undefined in my config.h. Can
> anyone shed any light on this?

That certainly shouldn't happen.

What version of autoconf is this?

It works for me with autoconf-2.53, given a configure.ac like this:

AC_INIT(foo,0.01)
AC_CONFIG_HEADERS(config.h)
AC_PROG_CC
AC_PROG_CC_STDC
AC_FUNC_MALLOC
AC_OUTPUT

then an `autoheader && autoconf --warnings=all && configure' gives me a
config.h.in that has the right template, and a config.h that does indeed
contain `#define HAVE_MALLOC 1'.

(You could probably get away without the AC_PROG_CC_STDC, but I put it
in automatically ;} thank god we don't need AC_ISC_POSIX anymore...)

-- 
`What happened?'
                 `Nick shipped buggy code!'
                                             `Oh, no dinner for him...'


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list