Log4cxx
  1. Log4cxx
  2. LOGCXX-14

add -Wall to compile log4cxx will get many warning

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.9.7
    • Fix Version/s: None
    • Component/s: Build
    • Labels:
      None

      Description

      When I build my project using log4cxx with -Wall ,it will get many warning. I think that why don't you use -Wall in log4cxx to check source code. it's very horrible to see these warning !

        Activity

        Hide
        Tom Nelson added a comment -

        This is a problem for me. I'm getting numerous messages of the form:

        ...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.

        Show
        Tom Nelson added a comment - This is a problem for me. I'm getting numerous messages of the form: ...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.
        Hide
        Tom Nelson added a comment -

        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!

        Show
        Tom Nelson added a comment - 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!
        Hide
        Marc Wäckerlin added a comment -

        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'

        Show
        Marc Wäckerlin added a comment - 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'
        Hide
        Marc Wäckerlin added a comment -

        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

        Show
        Marc Wäckerlin added a comment - 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
        Hide
        Marc Wäckerlin added a comment -

        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);

        Show
        Marc Wäckerlin added a comment - 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);
        Hide
        Andreas Fester added a comment -

        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).

        Show
        Andreas Fester added a comment - 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).
        Hide
        Rebecca Broadwater added a comment -

        I have successfully downloaded and built the latest log4cxx project however when I try to link the resulting .dll and .lib into my application I get the following unresolved externals specifically when I include the header file domconfigurator.h (I should note that I can include the header file logger.h in my application with no unresolved externals errors):

        Error 1 error LNK2019: unresolved external symbol "public: static class log4cxx::helpers::Class const & __cdecl log4cxx::rolling::Action::getStaticClass(void)" (?getStaticClass@Action@rolling@log4cxx@@SAABVClass@helpers@3@XZ) referenced in function "public: __thiscall log4cxx::helpers::ObjectPtrT<class log4cxx::rolling::Action>::ObjectPtrT<class log4cxx::rolling::Action>(class log4cxx::helpers::ObjectPtrBase const &)" (??0?$ObjectPtrT@VAction@rolling@log4cxx@@@helpers@log4cxx@@QAE@ABVObjectPtrBase@12@@Z)

        Error 2 error LNK2019: unresolved external symbol "public: static class log4cxx::helpers::Class const & __cdecl log4cxx::rolling::RolloverDescription::getStaticClass(void)" (?getStaticClass@RolloverDescription@rolling@log4cxx@@SAABVClass@helpers@3@XZ) referenced in function "public: __thiscall log4cxx::helpers::ObjectPtrT<class log4cxx::rolling::RolloverDescription>::ObjectPtrT<class log4cxx::rolling::RolloverDescription>(class log4cxx::helpers::ObjectPtrBase const &)" (??0?$ObjectPtrT@VRolloverDescription@rolling@log4cxx@@@helpers@log4cxx@@QAE@ABVObjectPtrBase@12@@Z)

        Any ideas as to what I could be doing wrong?

        Show
        Rebecca Broadwater added a comment - I have successfully downloaded and built the latest log4cxx project however when I try to link the resulting .dll and .lib into my application I get the following unresolved externals specifically when I include the header file domconfigurator.h (I should note that I can include the header file logger.h in my application with no unresolved externals errors): Error 1 error LNK2019: unresolved external symbol "public: static class log4cxx::helpers::Class const & __cdecl log4cxx::rolling::Action::getStaticClass(void)" (?getStaticClass@Action@rolling@log4cxx@@SAABVClass@helpers@3@XZ) referenced in function "public: __thiscall log4cxx::helpers::ObjectPtrT<class log4cxx::rolling::Action>::ObjectPtrT<class log4cxx::rolling::Action>(class log4cxx::helpers::ObjectPtrBase const &)" (??0?$ObjectPtrT@VAction@rolling@log4cxx@@@helpers@log4cxx@@QAE@ABVObjectPtrBase@12@@Z) Error 2 error LNK2019: unresolved external symbol "public: static class log4cxx::helpers::Class const & __cdecl log4cxx::rolling::RolloverDescription::getStaticClass(void)" (?getStaticClass@RolloverDescription@rolling@log4cxx@@SAABVClass@helpers@3@XZ) referenced in function "public: __thiscall log4cxx::helpers::ObjectPtrT<class log4cxx::rolling::RolloverDescription>::ObjectPtrT<class log4cxx::rolling::RolloverDescription>(class log4cxx::helpers::ObjectPtrBase const &)" (??0?$ObjectPtrT@VRolloverDescription@rolling@log4cxx@@@helpers@log4cxx@@QAE@ABVObjectPtrBase@12@@Z) Any ideas as to what I could be doing wrong?

          People

          • Assignee:
            Andreas Fester
            Reporter:
            hbzhang
          • Votes:
            3 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development