[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnulib bugs on OSX & C++
From: |
Bruno Haible |
Subject: |
Re: gnulib bugs on OSX & C++ |
Date: |
Thu, 13 May 2010 19:23:55 +0200 |
User-agent: |
KMail/1.9.9 |
Jarno Rajahalme wrote:
> > There are three possible ways to handle this:
> > a) Change the initializer from ::func to ((void)0,::func).
> > This has the effect of getting rid of the warning, but creates lots of
> > initialized variables in the 'data' segment, for every compilation unit.
> > I.e. it bloats the compiled code.
> > b) Change the warning to be enabled when !__OPTIMIZE__. This means that
> > with default optimization flags (-O2 -g), no warnings will be visible.
> > c) Leave it as it, and document that users should look at the warnings only
> > with -O0.
> >
> > I'm not sure which one you prefer?
>
> I personally would prefer b). Having hundreds of spurious warnings totally
> swamps any other possible warnings, that might be useful even when compiling
> with optimization.
OK, I'm implementing option b):
2010-05-13 Bruno Haible <address@hidden>
Avoid useless warnings from G++.
* build-aux/c++defs.h (_GL_CXXALIASWARN_2, _GL_CXXALIASWARN1_2): Don't
use _GL_WARN_ON_USE or _GL_WARN_ON_USE_CXX when optimizing.
Reported by Jarno Rajahalme <address@hidden>.
--- build-aux/c++defs.h.orig Thu May 13 19:19:34 2010
+++ build-aux/c++defs.h Thu May 13 19:18:43 2010
@@ -221,10 +221,20 @@
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \
_GL_CXXALIASWARN_2 (func, namespace)
-# define _GL_CXXALIASWARN_2(func,namespace) \
- _GL_WARN_ON_USE (func, \
- "The symbol ::" #func " refers to the system function. " \
- "Use " #namespace "::" #func " instead.")
+/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+ we enable the warning only when not optimizing. */
+# if !__OPTIMIZE__
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ _GL_WARN_ON_USE (func, \
+ "The symbol ::" #func " refers to the system function. " \
+ "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ extern __typeof__ (func) func
+# else
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
#else
# define _GL_CXXALIASWARN(func) \
_GL_EXTERN_C int _gl_cxxalias_dummy
@@ -239,10 +249,20 @@
GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace)
\
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
-# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace)
\
- _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
- "The symbol ::" #func " refers to the system function.
" \
- "Use " #namespace "::" #func " instead.")
+/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+ we enable the warning only when not optimizing. */
+# if !__OPTIMIZE__
+# define
_GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
+ "The symbol ::" #func " refers to the system
function. " \
+ "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+# define
_GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ extern __typeof__ (func) func
+# else
+# define
_GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
#else
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
_GL_EXTERN_C int _gl_cxxalias_dummy