Opened 8 years ago

Closed 8 years ago

#10535 closed Bugs (fixed)

Multiply Defined Symbols in serialization/wserialization

Reported by: Isaac Lascasas <isaaclascasas@…> Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.54.0 Severity: Regression
Keywords: Cc:

Description

When linking a windows clr dll (may happen with other configurations too), if you use both serialization and wserialization you should not be able to link because of a couple of symbols defined across two different modules (is_whitespace(char) and is_whitespace(wchar_t) in basic_text_iprimitive and basic_text_wiprimitive).

I solved the problem by changing this two files and rebuilding boost:

basic_text_iprimitive.ipp:

template<> bool is_whitespace(char t);

{ return 0 != std::isspace(t); }

#ifndef BOOST_NO_CWCHAR template<> bool is_whitespace(wchar_t t);

{ return 0 != std::iswspace(t); }

#endif

} detail

basic_text_iprimitive.cpp:

namespace detail {

template<class CharType> bool is_whitespace(CharType c);

template<> bool is_whitespace(char t) {

return 0 != std::isspace(t);

}

#ifndef BOOST_NO_CWCHAR template<> bool is_whitespace(wchar_t t) {

return 0 != std::iswspace(t);

} #endif

} detail

Change History (3)

comment:1 by Robert Ramey, 8 years ago

namespace detail {
    template<class CharType>
    bool is_whitespace(CharType c);

    template<>
    bool is_whitespace(char t){
        return 0 != std::isspace(t);
    }

    #ifndef BOOST_NO_CWCHAR
    template<>
    bool is_whitespace(wchar_t t){
        return 0 != std::iswspace(t);
    }
    #endif
} // detail

This is what my code in *.ipp already looks like - I don't understand the proposed change in *.cpp - doesn't look like the correct fix to me.

It seems to me that the symptom is multiply defined symbols in basic_text_iprimitive.ipp. Since this is old code - I'm guessing that the newer linker/managed code, etc is pickier. Even though the functions are inline - it looks like they are being linked with external linkage - I'll consider this.

Robert Ramey

comment:2 by Robert Ramey, 8 years ago

namespace detail {
    template<class CharType>
    static inline bool is_whitespace(CharType c);

    template<>
    inline bool is_whitespace(char t){
        return 0 != std::isspace(t);
    }

    #ifndef BOOST_NO_CWCHAR
    template<>
    inline bool is_whitespace(wchar_t t){
        return 0 != std::iswspace(t);
    }
    #endif
} // detail

I think that the above is the right fix - how does that work for you?

comment:3 by Robert Ramey, 8 years ago

Resolution: → fixed
Status: new → closed
Note: See TracTickets for help on using tickets.