Opened 14 years ago

Closed 14 years ago

#2544 closed Bugs (fixed)

BOOST_CLASS_EXPORT uses __LINE__ in variable declaration

Reported by: Emmet Spier <Emmet.Spier@…> Owned by: Robert Ramey
Milestone: Boost 1.38.0 Component: serialization
Version: Boost Development Trunk Severity: Showstopper
Keywords: boost >= 1.36 Cc:

Description

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

Change History (3)

comment:1 by Robert Ramey, 14 years ago

Status: newassigned

Problem is that T might might be a template instatiation like list<int> - so the proposed solution wouldnn't work for templates

in reply to:  1 comment:2 by anonymous, 14 years ago

Replying to ramey:

Problem is that T might might be a template instatiation like list<int> - so the proposed solution wouldnn't work for templates

I just submitted ticket #2569 which is unfortunately a duplicate of this ticket (my apologies for that). However, I did attach a patch to #2569 that fixed the issue in all of my use cases. It has not been run against any unit tests, so there may be unknown issues that invalidate it.

comment:3 by Robert Ramey, 14 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.