|
Boost Users : |
Subject: [Boost-users] [Units] Bug with BOOST_UNITS_STATIC_CONSTANT and precompiled headers on MSVC
From: David Walthall (walthall_at_[hidden])
Date: 2009-01-02 19:55:59
I think that I've run across a bug, either in Units, or in MSVC.
Because it only appears when precompiled headers are in use, I suspect
it may be a bug in MSVC. Basically, if BOOST_UNITS_STATIC_CONSTANT is
used in a header that is compiled into the precomiled header, there will
be linker errors.
Here is my information:
Microsoft Windows XP Professional x64 Edition
Microsoft Development Environment 2003 Version 7.1.6030
Microsoft Visual Studio .NET 2003 Service Pack 1 (KB918007)
Below is the minimial code to reproduce the error. There are 4 files,
stdafx.h, stdafx.cpp (which is used to create the pch), a.cpp, and
b.cpp. The same code without precompiled headers turned on links fine.
// start of stdafx.cpp
#include "stdafx.h"
// end of stdafx.cpp
// start of stdafx.h
#ifndef STDAFX_H_328A91DC_3924_466E_80EA_C9BB6CBF7638
#define STDAFX_H_328A91DC_3924_466E_80EA_C9BB6CBF7638
#include <boost/units/systems/si/length.hpp>
BOOST_UNITS_STATIC_CONSTANT(ONE_METER, boost::units::si::length);
#endif
// end of stdafx.h
// start of a.cpp
#include "stdafx.h"
int main(void)
{
boost::units::si::meter;
return 0;
}
// end of a.cpp
// start of b.cpp
#include "stdafx.h"
int main2(void)
{
boost::units::si::meter;
return 0;
}
// end of b.cpp
Here is the error message:
unit.obj : error LNK2005: "class unit<struct boost::units::list<struct
boost::units::dim<struct boost::units::length_base_dimension,class
boost::units::static_rational<1,1> >,struct
boost::units::dimensionless_type>,struct
boost::units::homogeneous_system<struct boost::units::list<struct
boost::units::si::meter_base_unit,struct boost::units::list<struct
boost::units::scaled_base_unit<struct
boost::units::cgs::gram_base_unit,struct boost::units::scale<10,class
boost::units::static_rational<3,1> > >,struct boost::units::list<struct
boost::units::si::second_base_unit,struct boost::units::list<struct
boost::units::si::ampere_base_unit,struct boost::units::list<struct
boost::units::si::kelvin_base_unit,struct boost::units::list<struct
boost::units::si::mole_base_unit,struct boost::units::list<struct
boost::units::si::candela_base_unit,struct boost::units::list<struct
boost::units::angle::radian_base_unit,struct boost::units::list<struct
boost::units::angle::steradian_base_unit,struct
boost::units::dimensionless_type> > > > > > > > >
>,void>::boost::unit<struct boost::units::list<struct
boost::units::dim<struct boost::units::length_base_dimension,class
boost::units::static_rational<1,1> >,struct
boost::units::dimensionless_type>,struct
boost::units::homogeneous_system<struct boost::units::list<struct
boost::units::si::meter_base_unit,struct boost::units::list<struct
boost::units::scaled_base_unit<struct
boost::units::cgs::gram_base_unit,struct boost::units::scale<10,class
boost::units::static_rational<3,1> > >,struct boost::units::list<struct
boost::units::si::second_base_unit,struct boost::units::list<struct
boost::units::si::ampere_base_unit,struct boost::units::list<struct
boost::units::si::kelvin_base_unit,struct boost::units::list<struct
boost::units::si::mole_base_unit,struct boost::units::list<struct
boost::units::si::candela_base_unit,struct boost::units::list<struct
boost::units::angle::radian_base_unit,struct boost::units::list<struct
boost::units::angle::steradian_base_unit,struct boost::units::dimensionless
type> > > > > > > > > >,void> const & const boost::units::si::`anonymous
namespace'::meter"
(?meter@?A0x490e06d9_at_si@units_at_boost@@3ABV?$unit_at_U?$list_at_U?$dim_at_Ulength_base_dimension_at_units@boost@@V?$static_rational@$00$00_at_23@@units_at_boost@@Udimensionless_type_at_23@@units_at_boost@@U?$homogeneous_system_at_U?$list_at_Umeter_base_unit_at_si@units_at_boost@@U?$list_at_U?$scaled_base_unit_at_Ugram_base_unit_at_cgs@units_at_boost@@U?$scale@$09V?$static_rational@$02$00_at_units@boost@@@34@@units_at_boost@@U?$list_at_Usecond_base_unit_at_si@units_at_boost@@U?$list_at_Uampere_base_unit_at_si@units_at_boost@@U?$list_at_Ukelvin_base_unit_at_si@units_at_boost@@U?$list_at_Umole_base_unit_at_si@units_at_boost@@U?$list_at_Ucandela_base_unit_at_si@units_at_boost@@U?$list_at_Uradian_base_unit_at_angle@units_at_boost@@U?$list_at_Usteradian_base_unit_at_angle@units_at_boost@@Udimensionless_type_at_34@@34@@34@@34@@34@@34@@34@@23@@34@@units_at_boost@@@23_at_X@34_at_B)
already defined in stdafx.obj
unit2.obj : error LNK2005: "class unit<struct boost::units::list<struct
boost::units::dim<struct boost::units::length_base_dimension,class
boost::units::static_rational<1,1> >,struct
boost::units::dimensionless_type>,struct
boost::units::homogeneous_system<struct boost::units::list<struct
boost::units::si::meter_base_unit,struct boost::units::list<struct
boost::units::scaled_base_unit<struct
boost::units::cgs::gram_base_unit,struct boost::units::scale<10,class
boost::units::static_rational<3,1> > >,struct boost::units::list<struct
boost::units::si::second_base_unit,struct boost::units::list<struct
boost::units::si::ampere_base_unit,struct boost::units::list<struct
boost::units::si::kelvin_base_unit,struct boost::units::list<struct
boost::units::si::mole_base_unit,struct boost::units::list<struct
boost::units::si::candela_base_unit,struct boost::units::list<struct
boost::units::angle::radian_base_unit,struct boost::units::list<struct
boost::units::angle::steradian_base_unit,struct
boost::units::dimensionless_type> > > > > > > > >
>,void>::boost::unit<struct boost::units::list<struct
boost::units::dim<struct boost::units::length_base_dimension,class
boost::units::static_rational<1,1> >,struct
boost::units::dimensionless_type>,struct
boost::units::homogeneous_system<struct boost::units::list<struct
boost::units::si::meter_base_unit,struct boost::units::list<struct
boost::units::scaled_base_unit<struct
boost::units::cgs::gram_base_unit,struct boost::units::scale<10,class
boost::units::static_rational<3,1> > >,struct boost::units::list<struct
boost::units::si::second_base_unit,struct boost::units::list<struct
boost::units::si::ampere_base_unit,struct boost::units::list<struct
boost::units::si::kelvin_base_unit,struct boost::units::list<struct
boost::units::si::mole_base_unit,struct boost::units::list<struct
boost::units::si::candela_base_unit,struct boost::units::list<struct
boost::units::angle::radian_base_unit,struct boost::units::list<struct
boost::units::angle::steradian_base_unit,struct boost::units::dimensionles
s_type> > > > > > > > > >,void> const & const
boost::units::si::`anonymous namespace'::meter"
(?meter@?A0x490e06d9_at_si@units_at_boost@@3ABV?$unit_at_U?$list_at_U?$dim_at_Ulength_base_dimension_at_units@boost@@V?$static_rational@$00$00_at_23@@units_at_boost@@Udimensionless_type_at_23@@units_at_boost@@U?$homogeneous_system_at_U?$list_at_Umeter_base_unit_at_si@units_at_boost@@U?$list_at_U?$scaled_base_unit_at_Ugram_base_unit_at_cgs@units_at_boost@@U?$scale@$09V?$static_rational@$02$00_at_units@boost@@@34@@units_at_boost@@U?$list_at_Usecond_base_unit_at_si@units_at_boost@@U?$list_at_Uampere_base_unit_at_si@units_at_boost@@U?$list_at_Ukelvin_base_unit_at_si@units_at_boost@@U?$list_at_Umole_base_unit_at_si@units_at_boost@@U?$list_at_Ucandela_base_unit_at_si@units_at_boost@@U?$list_at_Uradian_base_unit_at_angle@units_at_boost@@U?$list_at_Usteradian_base_unit_at_angle@units_at_boost@@Udimensionless_type_at_34@@34@@34@@34@@34@@34@@34@@23@@34@@units_at_boost@@@23_at_X@34_at_B)
already defined in stdafx.obj
Any insights would be appreciated.
Thanks,
David
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net