|
For me the fix was to add:
virtual ~Class() {} in log4cxx/helpers/class.h It would be great if someone who is a developer could get this in? Many thanks in advance! This is not only a problem in 0.9.7, but it still remains in the latest CVS from yesterday:
DO NOT USE THE SAME NAME FOR MEMBERS AND PARAMETERS! Please always check your code with all warnings enabled before CVS check-in! make[2]: Leaving directory `/privat/home/marc/siemens/errorhandling-caddie/example' g++ -DLOCATION='"zrh"' -pedantic-errors -Wall -W -Wfloat-equal -Wundef -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare -Wmissing-format-attribute -Wno-multichar -Wp acked -Wredundant-decls -Werror -Wshadow -Wcast-qual -Wno-ctor-dtor-privacy -I. -o logger.o \ logger.cpp -c /usr/local/include/log4cxx/helpers/objectptr.h: In copy constructor ` log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const log4cxx::helpers::ObjectPtrT<T>&) [with T = log4cxx::Logger]': logger.cpp:44: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:76: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h: In constructor ` log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::helpers::AppenderAttachableImpl*, T = log4cxx::helpers::Object]': /usr/local/include/log4cxx/helpers/appenderattachableimpl.h:50: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:38: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h: In member function `void log4cxx::helpers::ObjectPtrT<T>::cast(const InterfacePtr&) [with InterfacePtr = log4cxx::helpers::AppenderAttachableImpl*, T = log4cxx::helpers::Object]': /usr/local/include/log4cxx/helpers/objectptr.h:40: instantiated from `log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::helpers::AppenderAttachableImpl*, T = log4cxx::helpers::Object]' /usr/local/include/log4cxx/helpers/appenderattachableimpl.h:50: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:165: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h:174: warning: cast from `const void*' to `log4cxx::helpers::Object*' discards qualifiers from pointer target type /usr/local/include/log4cxx/helpers/objectptr.h: In copy constructor ` log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const log4cxx::helpers::ObjectPtrT<T>&) [with T = log4cxx::helpers::Object]': /usr/local/include/log4cxx/helpers/appenderattachableimpl.h:50: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:76: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h: In constructor ` log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::PropertyConfigurator*, T = log4cxx::helpers::Object] ': /usr/local/include/log4cxx/propertyconfigurator.h:101: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:38: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h: In member function `void log4cxx::helpers::ObjectPtrT<T>::cast(const InterfacePtr&) [with InterfacePtr = log4cxx::PropertyConfigurator*, T = log4cxx::helpers::Object] ': /usr/local/include/log4cxx/helpers/objectptr.h:40: instantiated from `log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::PropertyConfigurator*, T = log4cxx::h elpers::Object]' /usr/local/include/log4cxx/propertyconfigurator.h:101: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:165: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h:174: warning: cast from `const void*' to `log4cxx::helpers::Object*' discards qualifiers from pointer target type /usr/local/include/log4cxx/helpers/objectptr.h: In constructor ` log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::FileAppender*, T = log4cxx::helpers::Object]': /usr/local/include/log4cxx/fileappender.h:66: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:38: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h: In member function `void log4cxx::helpers::ObjectPtrT<T>::cast(const InterfacePtr&) [with InterfacePtr = log4cxx::FileAppender*, T = log4cxx::helpers::Object]': /usr/local/include/log4cxx/helpers/objectptr.h:40: instantiated from `log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::FileAppender*, T = log4cxx::helpers:: Object]' /usr/local/include/log4cxx/fileappender.h:66: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:165: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h:174: warning: cast from `const void*' to `log4cxx::helpers::Object*' discards qualifiers from pointer target type /usr/local/include/log4cxx/helpers/objectptr.h: In constructor ` log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::DailyRollingFileAppender*, T = log4cxx::helpers::Object]': /usr/local/include/log4cxx/dailyrollingfileappender.h:51: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:38: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h: In member function `void log4cxx::helpers::ObjectPtrT<T>::cast(const InterfacePtr&) [with InterfacePtr = log4cxx::DailyRollingFileAppender*, T = log4cxx::helpers::Object]': /usr/local/include/log4cxx/helpers/objectptr.h:40: instantiated from `log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::DailyRollingFileAppender*, T = log4cx x::helpers::Object]' /usr/local/include/log4cxx/dailyrollingfileappender.h:51: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:165: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h:174: warning: cast from `const void*' to `log4cxx::helpers::Object*' discards qualifiers from pointer target type /usr/local/include/log4cxx/helpers/objectptr.h: In copy constructor ` log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const log4cxx::helpers::ObjectPtrT<T>&) [with T = log4cxx::Appender]': logger.cpp:223: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:76: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h: In constructor ` log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::AppenderPtr, T = log4cxx::DailyRollingFileAppender] ': logger.cpp:224: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:38: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h: In member function `void log4cxx::helpers::ObjectPtrT<T>::cast(const InterfacePtr&) [with InterfacePtr = log4cxx::helpers::ObjectPtrT<log4cxx::Appender>, T = log4cxx::DailyRollingFileAppender]': /usr/local/include/log4cxx/helpers/objectptr.h:40: instantiated from `log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::AppenderPtr, T = log4cxx::DailyRollin gFileAppender]' logger.cpp:224: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:165: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h:40: instantiated from `log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::AppenderPtr, T = log4cxx::DailyRollin gFileAppender]' logger.cpp:224: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:174: warning: cast from `const void*' to `log4cxx::DailyRollingFileAppender*' discards qualifiers from pointer target type /usr/local/include/log4cxx/helpers/objectptr.h: In constructor ` log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::AppenderPtr, T = log4cxx::FileAppender]': logger.cpp:225: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:38: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h: In member function `void log4cxx::helpers::ObjectPtrT<T>::cast(const InterfacePtr&) [with InterfacePtr = log4cxx::helpers::ObjectPtrT<log4cxx::Appender>, T = log4cxx::FileAppender]': /usr/local/include/log4cxx/helpers/objectptr.h:40: instantiated from `log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::AppenderPtr, T = log4cxx::FileAppende r]' logger.cpp:225: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:165: warning: declaration of `p' shadows a member of `this' /usr/local/include/log4cxx/helpers/objectptr.h:40: instantiated from `log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::AppenderPtr, T = log4cxx::FileAppende r]' logger.cpp:225: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:174: warning: cast from `const void*' to `log4cxx::FileAppender*' discards qualifiers from pointer target type /usr/local/include/log4cxx/helpers/objectptr.h: In member function `bool log4cxx::helpers::ObjectPtrT<T>::operator!=(const T*) const [with T = log4cxx::Appender]': /usr/local/include/log4cxx/helpers/objectptr.h:172: instantiated from `void log4cxx::helpers::ObjectPtrT<T>::cast(const InterfacePtr&) [with InterfacePtr = log4cxx::helpers::ObjectPtrT<log4cxx::Appender >, T = log4cxx::DailyRollingFileAppender]' /usr/local/include/log4cxx/helpers/objectptr.h:40: instantiated from `log4cxx::helpers::ObjectPtrT<T>::ObjectPtrT(const InterfacePtr&) [with InterfacePtr = log4cxx::AppenderPtr, T = log4cxx::DailyRollin gFileAppender]' logger.cpp:224: instantiated from here /usr/local/include/log4cxx/helpers/objectptr.h:158: warning: declaration of `p' shadows a member of `this' All Problems are in objectptr.h
In addition to the parametername=membername problem, there's a very brutal cast at line 174. The following is a corrected version of objectptr.h: ------------------------------------------------------------------------------------------------------------------ /* * Copyright 2003,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LOG4CXX_HELPERS_OBJECT_PTR_H #define _LOG4CXX_HELPERS_OBJECT_PTR_H #include <log4cxx/log4cxx.h> namespace log4cxx { namespace helpers { class LOG4CXX_EXPORT ObjectPtrBase { public: static void checkNull(const int& null); }; /** smart pointer to a Object descendant */ template<typename T> class ObjectPtrT { public: template<typename InterfacePtr> ObjectPtrT(const InterfacePtr& p1) : p(0) { cast(p1); } // Disable conversion using ObjectPtrT* specialization of // template<typename InterfacePtr> ObjectPtrT(const InterfacePtr& p) /* template<> explicit ObjectPtrT(ObjectPtrT* const & p1) throw(IllegalArgumentException) { if (p1 == 0) { throw IllegalArgumentException(String()); } else { this->p = p1->p; this->p->addRef(); } }*/ ObjectPtrT(const int& null) //throw(IllegalArgumentException) : p(0) { ObjectPtrBase::checkNull(null); } ObjectPtrT() : p(0) { } ObjectPtrT(T * p1) : p(p1) { if (this->p != 0) { this->p->addRef(); } } ObjectPtrT(const ObjectPtrT& p1) : p(p1.p) { if (this->p != 0) { this->p->addRef(); } } ~ObjectPtrT() { if (this->p != 0) { this->p->releaseRef(); } } // Operators template<typename InterfacePtr> ObjectPtrT& operator=(const InterfacePtr& p1) { cast(p1); return *this; } ObjectPtrT& operator=(const ObjectPtrT& p1) { if (this->p != p1.p) { if (this->p != 0) { this->p->releaseRef(); } this->p = p1.p; if (this->p != 0) { this->p->addRef(); } } return *this; } ObjectPtrT& operator=(const int& null) //throw(IllegalArgumentException) { // // throws IllegalArgumentException if null != 0 // ObjectPtrBase::checkNull(null); if (this->p != 0) { this->p->releaseRef(); this->p = 0; } return *this; } ObjectPtrT& operator=(T* p1) { if (this->p != p1) { if (this->p != 0) { this->p->releaseRef(); } this->p = p1; if (this->p != 0) { this->p->addRef(); } } return *this; } bool operator==(const ObjectPtrT& p1) const { return (this->p == p1.p); } bool operator!=(const ObjectPtrT& p1) const { return (this->p != p1.p); } bool operator==(const T* p1) const { return (this->p == p1); } bool operator!=(const T* p1) const { return (this->p != p1); } T* operator->() {return p; } const T* operator->() const {return p; } T& operator*() const {return *p; } operator T*() const {return p; } template<typename InterfacePtr> void cast(const InterfacePtr& p1) { if (this->p != 0) { this->p->releaseRef(); this->p = 0; } if (p1 != 0) { this->p = reinterpret_cast<T*>(const_cast<void*>(p1->cast(T::getStaticClass()))); if (this->p != 0) { this->p->addRef(); } } } public: T * p; }; } } #endif //_LOG4CXX_HELPERS_OBJECT_PTR_H One more:
In file included from logger.cpp:22: /usr/local/include/log4cxx/xml/domconfigurator.h:243: error: extra qualification `log4cxx::xml::DOMConfigurator::' on member `subst' ignored Solution: change line from: LogString DOMConfigurator::subst(const LogString& value); to: LogString subst(const LogString& value); log4cxx now compiles on gcc 3.3 and gcc 4.1 with the following set of compiler switches:
-pedantic-errors -Wall -W -Wfloat-equal -Wundef -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare -Wmissing-format-attribute -Wno-multichar -Wpacked -Wredundant-decls -Werror -Wshadow -Wno-ctor-dtor-privacy -Wno-long-long The (inofficial) nightly integration build at http://littletux.homelinux.org/log4cxx/ also uses these compiler switches to make sure that no new issues of this kind are introduced (there is one issue with cppunit though: /usr/include/cppunit/extensions/ExceptionTestCaseDecorator.h:95: warning: unused parameter 'e', but this needs to be reported against cppunit). |
||||||||||||||||||||||||||||||||||||||||||||||||||
...include/log4cxx/propertyconfigurator.h:114: warning: `
class log4cxx::PropertyConfigurator::ClassPropertyConfigurator' has virtual
functions but non-virtual destructor
These at least are easy to clean up:
Just add
virtual PropertyConfigurator::~PropertyConfigurator() {} etc. to the header files.
Why is this an issue? Because I'm trying to get other interested in useing it and we have a -Wall policy.