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