[Boost-bugs] [Boost C++ Libraries] #2544: BOOST_CLASS_EXPORT uses __LINE__ in variable declaration

Subject: [Boost-bugs] [Boost C++ Libraries] #2544: BOOST_CLASS_EXPORT uses __LINE__ in variable declaration
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-11-28 12:05:11


#2544: BOOST_CLASS_EXPORT uses __LINE__ in variable declaration
-----------------------------------------------+----------------------------
 Reporter: Emmet Spier <Emmet.Spier_at_[hidden]> | Owner: ramey
     Type: Bugs | Status: new
Milestone: Boost 1.38.0 | Component: serialization
  Version: Boost Development Trunk | Severity: Showstopper
 Keywords: boost >= 1.36 |
-----------------------------------------------+----------------------------
 Bug
 ---
 Using boost serialization. Declaring various derived types in separate
 files. Each type has a corresponding:

 BOOST_CLASS_EXPORT or BOOST_CLASS_EXPORT_GUID

 Have two or more files with the BOOST_CLASS_EXPORT/_GUID on the SAME line.

 Obtain a compile "error C2371: '`anonymous-
 namespace'::boost_serialization_guid_initializer_29' : redefinition;
 different basic types"


 Diagnosis
 ---------

 Since (at least) boost 1.36 (not boost 1.34) in 'serialization/export.hpp'
 in the macro definition of BOOST_CLASS_EXPORT_GUID a variable is defined
 as so:

 BOOST_PP_CAT(boost_serialization_guid_initializer_, __LINE__)
  = ::boost::serialization::singleton< ...

 Clearly, by using __LINE__ every call to the macro *must be on a different
 line*, otherwise an error as above will occur.

 Proposed Solution
 -----------------

 I can't say that I know the ins and outs of boost too well but if
 '__LINE__' is replaced by 'T' -- a variable in the macro specifying the
 classname -- then the generated variable name will be guaranteed to be
 unique (and valid?)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2544>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC