2N/A# warn-on-use.m4 serial 2
2N/Adnl Copyright (C) 2010 Free Software Foundation, Inc.
2N/Adnl This file is free software; the Free Software Foundation
2N/Adnl gives unlimited permission to copy and/or distribute it,
2N/Adnl with or without modifications, as long as this notice is preserved.
2N/A
2N/A# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
2N/A# ---------------------------------------
2N/A# For each whitespace-separated element in the list of NAMES, define
2N/A# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
2N/A# even after being undefined as a macro.
2N/A#
2N/A# See warn-on-use.h for some hints on how to poison function names, as
2N/A# well as ideas on poisoning global variables and macros. NAMES may
2N/A# include global variables, but remember that only functions work with
2N/A# _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single
2N/A# header, but if the replacement header pulls in other headers because
2N/A# some systems declare functions in the wrong header, then INCLUDES
2N/A# should do likewise.
2N/A#
2N/A# If you assume C89, then it is generally safe to assume declarations
2N/A# for functions declared in that standard (such as gets) without
2N/A# needing gl_WARN_ON_USE_PREPARE.
2N/AAC_DEFUN([gl_WARN_ON_USE_PREPARE],
2N/A[
2N/A m4_foreach_w([gl_decl], [$2],
2N/A [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
2N/A [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
2N/A undefining macros.])])dnl
2N/A for gl_func in m4_flatten([$2]); do
2N/A AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
2N/A AC_CACHE_CHECK([whether $gl_func is declared without a macro],
2N/A gl_Symbol,
2N/A [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
2N/A[@%:@undef $gl_func
2N/A (void) $gl_func;])],
2N/A [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
2N/A AS_VAR_IF(gl_Symbol, [yes],
2N/A [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
2N/A dnl shortcut - if the raw declaration exists, then set a cache
2N/A dnl variable to allow skipping any later AC_CHECK_DECL efforts
2N/A eval ac_cv_have_decl_$gl_func=yes])
2N/A AS_VAR_POPDEF([gl_Symbol])dnl
2N/A done
2N/A])