Opened 17 years ago

Closed 17 years ago

#498 closed Bugs (Works For Me)

Compiler warning with gcc on Linux

Reported by: nobody Owned by: Robert Ramey
Milestone: Component: serialization
Version: None Severity:
Keywords: Cc:

Description

I get the following warning compiling on Linux with
gcc.  No mater what I do I can't seem to get around the
warning.  Any ideas?  Thanks!

g++ -c -pipe -Wall -W -g -fPIC  
-I/usr/lib/qt-3.1/mkspecs/default -I. -I. -Iinclude
-Isrc -I../ccbus -I/usr/lib/qt-3.1/include -I.ui/
-I.moc/ -o .obj/TraderButtonKey.o src/TraderButtonKey.cpp
/usr/include/boost/archive/detail/common_iarchive.hpp:
In member function `void
  
boost::archive::detail::common_iarchive<Archive>::init()
[with Archive =
   boost::archive::text_iarchive]':
/usr/include/boost/archive/text_iarchive.hpp:69:  
instantiated from
`boost::archive::text_iarchive_impl<Archive>::text_iarchive_impl(std::istream&,
unsigned int) [with Archive =
boost::archive::text_iarchive]'
/usr/include/boost/archive/text_iarchive.hpp:82:  
instantiated from here
/usr/include/boost/archive/detail/common_iarchive.hpp:75:
warning: choosing `
   boost::archive::version_type::operator unsigned
int&()' over `
   boost::archive::version_type::operator unsigned
int() const'
/usr/include/boost/archive/detail/common_iarchive.hpp:75:
warning:   for
   conversion from `boost::archive::version_type' to
`unsigned int'
/usr/include/boost/archive/detail/common_iarchive.hpp:75:
warning:   because
   conversion sequence for the argument is better

Code fragment:

class TraderButtonKey
{
	
public:

    //! Default constructor.

    TraderButtonKey( ) : m_cls(0), m_number(0) {}

    //! Constructor.
    //!
    //! \param cls                     the class
    //! \param number                  the number

    TraderButtonKey( int cls, int number ) :
m_cls(cls), m_number(number) {}

...

private:

    //! Required by the boost C++ libraries to provide
serialization to
    //! and from the archive.
    //!
    //! \param ar                      archive to
save/load object members
    //! \param version                 boost class version

    template<class Archive> void serialize( Archive &
ar, const unsigned int version )
    {

        if (version)    // gets rid of unused parameter
warning
            ;

        ar & m_cls;
        ar & m_number;
    }

    int m_cls;                         //!< class of
the key
    int m_number;                      //!< number
within that class
};

Change History (6)

comment:1 by nobody, 17 years ago

Logged In: NO 

Ooops ... forgot my email ... rbys@hotmail.com ... thanks!

comment:2 by nobody, 17 years ago

Logged In: NO 

Ooops ... forgot my email ... rbys@hotmail.com ... thanks!

comment:3 by straszheim, 17 years ago

Logged In: YES 
user_id=167007

I've seen these too, FWIW, with (I believe) gcc 3.2.3.  What
boost version/compiler are you using?

This patch:

75c75
<        
basic_iarchive::init(input_library_version.operator unsigned
int());
---
>         basic_iarchive::init(input_library_version);

to boost/archive/detail/common_iarchive.hpp stops the
warning for version 1.32.0.  IIRC.  Haven't doublechecked
with Robert if this is completely kosher or not, though...

-troy d. straszheim

comment:4 by nobody, 17 years ago

Logged In: NO 

Ooops ... forgot my email ... rbys@hotmail.com ... thanks!

comment:5 by nobody, 17 years ago

Logged In: NO 

Ooops ... forgot my email ... rbys@hotmail.com ... thanks!

comment:6 by Robert Ramey, 17 years ago

Status: assignedclosed
Logged In: YES 
user_id=396141

Bogus warning.  See manual.  In any event, code was tweaked 
to avoid generation of the message on this compiler

Robert Ramey

Note: See TracTickets for help on using tickets.