The autoconf documentation has this to say about the standard C headers:

     On systems without ANSI C headers, there is so much variation that
     it is probably easier to declare the functions you use than to
     figure out exactly what the system header files declare.  Some
     systems contain a mix of functions ANSI and BSD; some are mostly
     ANSI but lack `memmove'; some define the BSD functions as macros in
     `string.h' or `strings.h'; some have only the BSD functions but
     `string.h'; some declare the memory functions in `memory.h', some
     in `string.h'; etc.  It is probably sufficient to check for one
     string function and one memory function; if the library has the
     ANSI versions of those then it probably has most of the others.
     If you put the following in `configure.in':

          AC_HEADER_STDC
          AC_CHECK_FUNCS(strchr memcpy)

     then, in your code, you can put declarations like this:

          #if STDC_HEADERS
          # include <string.h>
          #else
          # ifndef HAVE_STRCHR
          #  define strchr index
          #  define strrchr rindex
          # endif
          char *strchr (), *strrchr ();
          # ifndef HAVE_MEMCPY
          #  define memcpy(d, s, n) bcopy ((s), (d), (n))
          #  define memmove(d, s, n) bcopy ((s), (d), (n))
          # endif
          #endif

But autoconf itself doesn't do this; it instead goes to some lengths to
track down the appropriate headers and include them rather than using its
own prototypes.  For example, see ac_include_default in acgeneral.m4.

Which is the right way of doing it?

-- 
Russ Allbery ([EMAIL PROTECTED])             <http://www.eyrie.org/~eagle/>

Reply via email to