Date: Sun, 27 Feb 2000 15:06:31 -0500
From: Harlan Stenn <[EMAIL PROTECTED]>
One problem with a "provide decl" check is that different systems need
different declarations for the same function.
The macro only checks whether the function is declared at all.
My experience is that portable code should never under any
circumstances declare functions which are declared in system header
files.
However, on some systems some functions are not declared at all, and
if you take the address of the function you need a declaration. The
purpose of the binutils macro is to check whether the function is
declared at all, with any meaning. If it is, then all is well. If it
is not, the binutils add an explicit declaration.
That is:
#ifdef NEED_DECLARATION_FPRINTF
extern int fprintf PARAMS ((FILE *, const char *, ...));
#endif
While it's no fun, the NTP configure.in does things like this:
case "$target" in
changequote(<<, >>)dnl
*-*-osf[45]*)
changequote([, ])dnl
AC_DEFINE(DECL_PLOCK_0)
AC_DEFINE(DECL_STIME_1)
;;
*-*-riscos4*)
AC_DEFINE(DECL_ADJTIME_0)
AC_DEFINE(DECL_BZERO_0)
AC_DEFINE(DECL_IOCTL_0)
AC_DEFINE(DECL_IPC_0)
AC_DEFINE(DECL_MEMMOVE_0)
...
acconfig.h has things like:
/* setitimer()? */
#undef DECL_SETITIMER_0
/* setpriority()? */
#undef DECL_SETPRIORITY_0
#undef DECL_SETPRIORITY_1
and one of the distribution headers contains lines like:
#ifdef DECL_SETPRIORITY_0
extern int setpriority P((int, int, int));
#endif
#ifdef DECL_SETPRIORITY_1
extern int setpriority P((int, id_t, int));
#endif
I think this is a bad choice for portability. NTP should instead use
autoconf to see which header file the function is declared in; e.g.,
sys/resource.h. Only if the function is not declared anywhere should
NTP use an explicit declaration; in that case, int, int, int should be
safe.
I used to write configuration code like this too, until I realized
that it was a bad idea. I've never regretted giving it up.
Ian