VC++7.1 problem with swallow_assign multiple definitions

Hi, I'm trying to port some code from VC++6.0 to VC++7.1. It is a DLL library that uses Boost.Python (from 1.30.2) to expose its interface for Python. It compiled without problems on VC++6.0, now I get during linking: file2.obj : error LNK2005: "struct swallow_assign::boost::detail::swallow_assign boost::tuples::`anonymous namespace'::ignore" (?ignore@?A0x3ab6eb85@tuples@boost@@3Uswallow_assign@detail@23@A) already defined in file1.obj and later: file2.obj : warning LNK4006: "struct swallow_assign::boost::detail::swallow_assign boost::tuples::`anonymous namespace'::ignore" (?ignore@?A0x3ab6eb85@tuples@boost@@3Uswallow_assign@detail@23@A) already defined in file1.obj; second definition ignored I found here: http://mail.python.org/pipermail/c++-sig/2002-November/002693.html the suggestion to use the latest tuple_basic_no_partial_spec.hpp file. No luck. I understand that it is the last line in this file that is a cause of problems. We would like to avoid upgrading to 1.31 if 1.30.2 can make it. Any suggestion for workaround will be highly appreciated. -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/

Maciej Sobczak wrote:
Hi,
I'm trying to port some code from VC++6.0 to VC++7.1. It is a DLL library that uses Boost.Python (from 1.30.2) to expose its interface for Python. It compiled without problems on VC++6.0, now I get during linking:
file2.obj : error LNK2005: "struct swallow_assign::boost::detail::swallow_assign boost::tuples::`anonymous namespace'::ignore" (?ignore@?A0x3ab6eb85@tuples@boost@@3Uswallow_assign@detail@23@A) already defined in file1.obj
and later:
file2.obj : warning LNK4006: "struct swallow_assign::boost::detail::swallow_assign boost::tuples::`anonymous namespace'::ignore" (?ignore@?A0x3ab6eb85@tuples@boost@@3Uswallow_assign@detail@23@A) already defined in file1.obj; second definition ignored
If you are using precompiled headers, try making 'ignore' static. boost/bind/placeholders.hpp has the same problem.

Hi, Peter Dimov wrote:
If you are using precompiled headers, try making 'ignore' static. boost/bind/placeholders.hpp has the same problem.
Bingo. The problem is that the web page I referenced in my previous post was suggesting replacing the tuple_basic_no_partial_spec.hpp file, where the "static" keyword was added for MSVC++. The fun is that this file is meant for compilers that do not support partial template specializations. MS VC++7.1 supports PTS, so it is the other file: tuple_basic.hpp that needs to be checked. I've made ignore static by doing this: namespace { #if (defined(BOOST_MSVC) && BOOST_MSVC <= 1310) || (defined(__DECCXX_VER) && __DECCXX_VER <= 60590031) static #endif detail::swallow_assign ignore; } instead of: namespace { detail::swallow_assign ignore; } Please note the 1310 value. It means MSVC++7.1. The other file that you suggested checking (placeholders.hpp) needed the value 1300 to be changed to 1310 (for MSVC++7.1 to be covered) so that all _1, _2, ... variables are made static. Now, after hacking these two files, all is OK. Thank you very much for your time, -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/
participants (2)
-
Maciej Sobczak
-
Peter Dimov