Date: Sat, 26 Feb 2000 14:59:49 +0500 (KGT)
   From: CyberPsychotic <[EMAIL PROTECTED]>

    What I am actually trying to figure out is whether certain function
   prototypes (printf, fprintf etc) are defined in includes by passing
   -pedantic-error switch to compiler. I've got a few notices that on SunOS
   4.x you get a bunch of warnings on `printf', `fprintf' and other libc
   functions which are supposed to be defined in <stdio.h> but due to some
   odd reason are not.

They are not defined on SunOS because SunOS is not an ANSI C compliant
system, and never has been.  It doesn't even ship with an ANSI C
compiler.

The GNU binutils use this macro to detect this case:

dnl See whether we need a declaration for a function.
AC_DEFUN(BFD_NEED_DECLARATION,
[AC_MSG_CHECKING([whether $1 must be declared])
AC_CACHE_VAL(bfd_cv_decl_needed_$1,
[AC_TRY_COMPILE([
#include <stdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#else
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif],
[char *(*pfn) = (char *(*)) $1],
bfd_cv_decl_needed_$1=no, bfd_cv_decl_needed_$1=yes)])
AC_MSG_RESULT($bfd_cv_decl_needed_$1)
if test $bfd_cv_decl_needed_$1 = yes; then
  AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
            [Define if $1 is not declared in system header files.])
fi
])dnl

It is used like this:

BFD_NEED_DECLARATION(fprintf)

This will define NEED_DECLARATION_FPRINTF if fprintf must be
explicitly declared.

Ian

Reply via email to