Paul Eggert <[EMAIL PROTECTED]> writes: > "Mark D. Baushke" <[EMAIL PROTECTED]> writes: > >> If you must check for it being defined, wouldn't this form >> >> #if !defined HAVE_DECL_STRNLEN || !HAVE_DECL_STRNLEN > > In the old days we were worried about people using gnulib .c files > without using the corresponding .m4 code. In such a case, > HAVE_DECL_STRNLEN wouldn't be defined, but the code still shouldn't > declare strnlen. > > These days the gnulib packaging process pretty much makes these > concerns obsolete. So it's OK to use "#if !HAVE_DECL_STRNLEN" > nowadays, I think.
The autoconf manual still suggests to use the former. Perhaps that wording can be relaxed further... Unlike the other `AC_CHECK_*S' macros, when a SYMBOL is not declared, `HAVE_DECL_SYMBOL' is defined to `0' instead of leaving `HAVE_DECL_SYMBOL' undeclared. When you are _sure_ that the check was performed, use `HAVE_DECL_SYMBOL' just like any other result of Autoconf: #if !HAVE_DECL_SYMBOL extern char *symbol; #endif If the test may have not been performed, however, because it is safer _not_ to declare a symbol than to use a declaration that conflicts with the system's one, you should use: #if defined HAVE_DECL_MALLOC && !HAVE_DECL_MALLOC void *malloc (size_t *s); #endif You fall into the second category only in extreme situations: either your files may be used without being configured, or they are used during the configuration. In most cases the traditional approach is enough.