changeset 13020:0c8447d33973

Make _GL_WARN_ON_USE usable in C++ and C mode in the same compilation unit.
author Bruno Haible <bruno@clisp.org>
date Sun, 21 Mar 2010 00:50:39 +0100
parents d30e3f8663c2
children 239c17119e60
files ChangeLog build-aux/warn-on-use.h
diffstat 2 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-03-20  Bruno Haible  <bruno@clisp.org>
+
+	Make _GL_WARN_ON_USE usable in C++ and C mode in the same compilation.
+	* build-aux/warn-on-use.h (_GL_WARN_EXTERN_C): New macro.
+	(_GL_WARN_ON_USE, _GL_WARN_ON_USE_CXX): Likewise.
+	Reported by John W. Eaton <jwe@gnu.org>.
+
 2010-03-20  Bruno Haible  <bruno@clisp.org>
 
 	* m4/unlink.m4 (gl_FUNC_UNLINK): Fix last commit.
--- a/build-aux/warn-on-use.h
+++ b/build-aux/warn-on-use.h
@@ -70,7 +70,7 @@
 
 # else /* Unsupported.  */
 #  define _GL_WARN_ON_USE(function, message) \
-extern int _gl_warn_on_use
+_GL_WARN_EXTERN_C int _gl_warn_on_use
 # endif
 #endif
 
@@ -87,6 +87,16 @@
      __attribute__ ((__warning__ (msg)))
 # else /* Unsupported.  */
 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
-extern int _gl_warn_on_use
+_GL_WARN_EXTERN_C int _gl_warn_on_use
 # endif
 #endif
+
+/* _GL_WARN_EXTERN_C declaration;
+   performs the declaration with C linkage.  */
+#ifndef _GL_WARN_EXTERN_C
+# if defined __cplusplus
+#  define _GL_WARN_EXTERN_C extern "C"
+# else
+#  define _GL_WARN_EXTERN_C extern
+# endif
+#endif