| Am Mon, 06 Mar 2000 schrieb Akim Demaille:
| >| OK, how about this one?
| >
| >Sorry, I don't mean to be pain, but I still have some comments :) Do
| >the other people consider I am being painful? (Real question)
|
| A real pein :-).
:)
| >Still, my comment would be that
| >
| >| #ifdef __cplusplus
| >| -extern "C" { void *malloc(unsigned); }
| >| +# ifdef HAVE_STDLIB_H
| >| +# include <stdlib.h>
| >| +# endif
| >| +# ifdef HAVE_UNISTD_H
| >| +# include <unistd.h>
| >| +# endif
| >| +# ifdef HAVE_SYS_STAT_H
| >| +# include <sys/stat.h>
| >| +# endif
| >| #else
| >| -char *malloc();
| >| +char *malloc ();
| >| #endif
| >
| >I would not condition the includes by __cplusplus, since the C
| >compiler will be happy too to have them. What do other people think?
| >Also, ifdef and ifndef are banished from Autoconf, use only #if and
| >#if !.
|
| Banished from autoconf? Why? What do you gain with that rule?
Stylistic, and actually for some macros such as AC_CHECK_DECLS, it
does make a difference. I should emphasize this in the doc actually.
| >How about
| >
| >#if HAVE_STDLIB_H
| ># include <stdlib.h>
| >#else
| >char *malloc ();
| >#endif
| >#if HAVE_UNISTD_H
| ># include <unistd.h>
| >#endif
| >#if HAVE_SYS_STAT_H
| ># include <sys/stat.h>
| >#endif
|
| Well, I don't want to revamp the whole testcase, I just want to fix a single
| bug under certain circumstances (g++ >= 2.95, glibc, linux). Note that I didn't
| add the __cplusplus in the first place, but someone did and someone decided
| to _not_ include stdlib.h in the first place to get a c++-safe
| malloc-prototype. Thinking about it I actually believe my previous patch was
| better, it didn't assume that the system header files are properly wrapped with
| extern "C".
The fact is that Autoconf must advocate the best of all the solutions,
since people usually inspire themselves from acspecific.m4, this is
why I'm a pain.
In present case, I don't think someone ever decided to _not_ include
stdlib.h in the first place to get a c++-safe malloc-prototype. It is
just that it has never been thought for C++, so there was a KnR proto,
which is not good for C++, then a proper malloc proto is given for C++
only, since Autoconf still works for KnR C compilers.
I think the solution proposed is the best of all: it is not imaginable
that a C++ compiler will have stdlib that does not prototype malloc,
so it is enough, and for C compilers without stdlib.h, the KnR proto
is enough.
Akim