The fopen() override leads to a compilation error on AIX. What happens: - The system's <stdio.h> defines #define fopen fopen64 before providing a declaration for fopen. - gnulib's fopen.c defines rpl_fopen() with an invocation to a #undef'ed fopen. But this has never been declared and therefore an assignment from its return value to 'FILE *' fails.
I'm applying this, and similarly for freopen() and open(). 2008-09-28 Bruno Haible <[EMAIL PROTECTED]> Override fopen more carefully. * lib/fopen.c (orig_fopen): New function. (rpl_fopen): Use orig_fopen instead of open. * m4/fopen.m4 (gl_PREREQ_FOPEN): New macro. (gl_FUNC_FOPEN): Invoke it. Needed on AIX. Reported by Rainer Tammer <[EMAIL PROTECTED]>. --- lib/fopen.c.orig 2008-09-28 16:08:39.000000000 +0200 +++ lib/fopen.c 2008-09-28 15:16:35.000000000 +0200 @@ -18,6 +18,17 @@ #include <config.h> +/* Get the original definition of fopen. It might be defined as a macro. */ +#define __need_FILE +#include <stdio.h> +#undef __need_FILE + +static inline FILE * +orig_fopen (const char *filename, const char *mode) +{ + return fopen (filename, mode); +} + /* Specification. */ #include <stdio.h> @@ -28,7 +39,6 @@ FILE * rpl_fopen (const char *filename, const char *mode) -#undef fopen { #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ if (strcmp (filename, "/dev/null") == 0) @@ -89,5 +99,5 @@ } # endif - return fopen (filename, mode); + return orig_fopen (filename, mode); } --- m4/fopen.m4.orig 2008-09-28 16:08:39.000000000 +0200 +++ m4/fopen.m4 2008-09-28 15:18:27.000000000 +0200 @@ -1,4 +1,4 @@ -# fopen.m4 serial 2 +# fopen.m4 serial 3 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -43,8 +43,15 @@ [Define to 1 if fopen() fails to recognize a trailing slash.]) REPLACE_FOPEN=1 AC_LIBOBJ([fopen]) + gl_PREREQ_FOPEN ;; esac ;; esac ]) + +# Prerequisites of lib/fopen.c. +AC_DEFUN([gl_PREREQ_FOPEN], +[ + AC_REQUIRE([AC_C_INLINE]) +])