warn-on-use.m4 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # warn-on-use.m4 serial 2
  2. dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. # gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
  7. # ---------------------------------------
  8. # For each whitespace-separated element in the list of NAMES, define
  9. # HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
  10. # even after being undefined as a macro.
  11. #
  12. # See warn-on-use.h for some hints on how to poison function names, as
  13. # well as ideas on poisoning global variables and macros. NAMES may
  14. # include global variables, but remember that only functions work with
  15. # _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single
  16. # header, but if the replacement header pulls in other headers because
  17. # some systems declare functions in the wrong header, then INCLUDES
  18. # should do likewise.
  19. #
  20. # If you assume C89, then it is generally safe to assume declarations
  21. # for functions declared in that standard (such as gets) without
  22. # needing gl_WARN_ON_USE_PREPARE.
  23. AC_DEFUN([gl_WARN_ON_USE_PREPARE],
  24. [
  25. m4_foreach_w([gl_decl], [$2],
  26. [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
  27. [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
  28. undefining macros.])])dnl
  29. for gl_func in m4_flatten([$2]); do
  30. AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
  31. AC_CACHE_CHECK([whether $gl_func is declared without a macro],
  32. gl_Symbol,
  33. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
  34. [@%:@undef $gl_func
  35. (void) $gl_func;])],
  36. [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
  37. AS_VAR_IF(gl_Symbol, [yes],
  38. [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
  39. dnl shortcut - if the raw declaration exists, then set a cache
  40. dnl variable to allow skipping any later AC_CHECK_DECL efforts
  41. eval ac_cv_have_decl_$gl_func=yes])
  42. AS_VAR_POPDEF([gl_Symbol])dnl
  43. done
  44. ])