Use GL_LINK_WARNING in the generated inttypes.h.
authorBruno Haible <bruno@clisp.org>
Sun, 18 Feb 2007 02:02:26 +0000 (02:02 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 18 Feb 2007 02:02:26 +0000 (02:02 +0000)
ChangeLog
lib/inttypes_.h
modules/imaxabs
modules/imaxdiv
modules/inttypes
modules/strtoimax
modules/strtoumax

index 54e1f07..4682931 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2007-02-17  Bruno Haible  <bruno@clisp.org>
 
+       * lib/inttypes_.h: Add definition for GL_LINK_WARNING.
+       (imaxabs, imaxdiv, strtoimax, strtoumax): Don't declare the function
+       if the corresponding module is not enabled. Emit link warnings if
+       the function is used nevertheless.
+       * m4/inttypes_h.m4 (gl_INTTYPES_H): Never use the existing <inttypes.h>.
+       Don't AC_SUBST HAVE_DECL_IMAXABS, HAVE_DECL_IMAXDIV,
+       HAVE_DECL_STRTOIMAX, HAVE_DECL_STRTOUMAX.
+       (gl_INTTYPES_MODULE_INDICATOR, gl_INTTYPES_H_DEFAULTS): New macros.
+       * modules/inttypes (Depends-on): Add link-warning.
+       (Makefile.am): Copy the contents of build-aux/link-warning.h into
+       inttypes.h.
+       * modules/imaxabs (configure.ac): Invoke gl_INTTYPES_MODULE_INDICATOR.
+       * modules/imaxdiv (configure.ac): Likewise.
+       * modules/strtoimax (configure.ac): Likewise.
+       * modules/strtoumax (configure.ac): Likewise.
+       
+2007-02-17  Bruno Haible  <bruno@clisp.org>
+
        * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Include the contents of
        gl_STRING_MODULE_INDICATOR_DEFAULTS.
        (gl_STRING_MODULE_INDICATOR_DEFAULTS): Remove macro.
index 2379540..97ab3ad 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2006-2007 Free Software Foundation, Inc.
    Written by Paul Eggert, Bruno Haible, Derek Price.
    This file is part of gnulib.
 
@@ -42,6 +42,8 @@
 # error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>."
 #endif
 
+/* The definition of GL_LINK_WARNING is copied here.  */
+
 /* 7.8.1 Macros for format specifiers */
 
 #if ! defined __cplusplus || defined __STDC_FORMAT_MACROS
 extern "C" {
 #endif
 
-#if !@HAVE_DECL_IMAXABS@
+#if @GNULIB_IMAXABS@
+# if !@HAVE_DECL_IMAXABS@
 extern intmax_t imaxabs (intmax_t);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef imaxabs
+# define imaxabs(a) \
+    (GL_LINK_WARNING ("imaxabs is unportable - "\
+                      "use gnulib module imaxabs for portability"), \
+     imaxabs (a))
 #endif
 
-#if !@HAVE_DECL_IMAXDIV@
+#if @GNULIB_IMAXDIV@
+# if !@HAVE_DECL_IMAXDIV@
 typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
 extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef imaxdiv
+# define imaxdiv(a,b) \
+    (GL_LINK_WARNING ("imaxdiv is unportable - "\
+                      "use gnulib module imaxdiv for portability"), \
+     imaxdiv (a, b))
 #endif
 
-#if !@HAVE_DECL_STRTOIMAX@
+#if @GNULIB_STRTOIMAX@
+# if !@HAVE_DECL_STRTOIMAX@
 extern intmax_t strtoimax (const char *, char **, int);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strtoimax
+# define strtoimax(p,e,b) \
+    (GL_LINK_WARNING ("strtoimax is unportable - "\
+                      "use gnulib module strtoimax for portability"), \
+     strtoimax (p, e, b))
 #endif
-#if !@HAVE_DECL_STRTOUMAX@
+
+#if @GNULIB_STRTOUMAX@
+# if !@HAVE_DECL_STRTOUMAX@
 extern uintmax_t strtoumax (const char *, char **, int);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strtoumax
+# define strtoumax(p,e,b) \
+    (GL_LINK_WARNING ("strtoumax is unportable - "\
+                      "use gnulib module strtoumax for portability"), \
+     strtoumax (p, e, b))
 #endif
 
 /* Don't bother defining or declaring wcstoimax and wcstoumax, since
index 1b0b50c..481486d 100644 (file)
@@ -10,6 +10,7 @@ inttypes
 
 configure.ac:
 gl_FUNC_IMAXABS
+gl_INTTYPES_MODULE_INDICATOR([imaxabs])
 
 Makefile.am:
 
index 621d1f3..7eacbc7 100644 (file)
@@ -10,6 +10,7 @@ inttypes
 
 configure.ac:
 gl_FUNC_IMAXDIV
+gl_INTTYPES_MODULE_INDICATOR([imaxdiv])
 
 Makefile.am:
 
index c2b8885..804deb9 100644 (file)
@@ -8,6 +8,7 @@ m4/inttypes.m4
 
 Depends-on:
 absolute-header
+link-warning
 stdint
 
 configure.ac:
@@ -31,6 +32,7 @@ inttypes.h: inttypes_.h
              -e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \
              -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
              -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
+             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/inttypes_.h; \
        } > $@-t
        mv $@-t $@
index 4e6da27..0a299c8 100644 (file)
@@ -14,6 +14,7 @@ stdint
 
 configure.ac:
 gl_FUNC_STRTOIMAX
+gl_INTTYPES_MODULE_INDICATOR([strtoimax])
 
 Makefile.am:
 
index 169f28f..8278e4e 100644 (file)
@@ -14,6 +14,7 @@ stdint
 
 configure.ac:
 gl_FUNC_STRTOUMAX
+gl_INTTYPES_MODULE_INDICATOR([strtoumax])
 
 Makefile.am: