Re: [GD-Windows] VS 2003 generating duplicate COMDAT for template instantiation?
Brought to you by:
vexxed72
From: Kent Q. <ken...@co...> - 2007-05-12 04:37:15
|
Well, my template-fu is a bit underused on my current project, so I can't look at this and give you a solution. But try this: chop this code down into the smallest compileable file you can, and then feed it to GCC 4 and maybe the Comeau computing compiler test page: http://www.comeaucomputing.com/tryitout/ I've found in the past that when I've had tricky template troubles, one or the other of those compilers will generate some message that will give me a clue. I know this is failing on the link, but if you turn on maximum warnings, I wouldn't be surprised to have one of these compilers spit out a warning or an error. Kent Jon Watte wrote: > I'm trying to generate a SAS parser/binder using just a little bit of > template programing, and I'm running into the following link error (I'm > using VS 2003). I would like any help I can get in how to work around > this problem. I got it when I was reinterpret_cast-ing from type > Foo::*Bar[N] to Foo::*Bar[], but I worked around that by explicitly > passing in the array size. However, here there are no skanky casts > involved; this should "just work." (And I've tried with and without the > inline Access() function). > > > Win32DX9Graphics.obj : fatal error LNK1179: invalid or corrupt file: > duplicate COMDAT > '?Access@?$FieldAccessor@USasAmbientLight@impl_DX9@@VFastTriple@pit@@$GA@A@A@@impl_DX9@@QAEABVFastTriple@pit@@ABUSasAmbientLight@2@@Z' > > Looking at the templates FieldAccessor, here is the code: > > > template<typename Container, typename Type, Type Container::*Field> > class FieldAccessor { > public: > typedef Container ContainerType; > typedef Type FieldType; > inline Type const &Access(Container const &c) { return c.*Field; } > }; > > > Here are the two cases where FieldAccessor<> is referenced for the > SasAmbientLight: > > > // dispatch the child > if (!wcscmp(path, L"color")) { > setter_ = PIT_SYSTEMNEW0("ValueSetter") ValueSetter< > FieldAccessor<SasAmbientLight, pit::FloatTriple, > &SasAmbientLight::color> > > (this, core_->ambientlight_[l]); > return true; > } > return false; > > ... > > // dispatch the child, then return an iterator on that > if (!wcscmp(path, L"color")) { > setter_ = PIT_SYSTEMNEW0("OuterArraySetter") OuterArraySetter< > FieldAccessor<SasAmbientLight, pit::FloatTriple, > &SasAmbientLight::color> > > (this, core_->ambientlight_, &core_->numambientlights_.get()); > return true; > } > return false; > > > > pit::FloatTriple is what you'd expect, as is struct SasAmbientLight: > > struct SasAmbientLight { > pit::FloatTriple color; > }; > > > > Btw: upgrading to 2005 isn't the preferred solution right now. > > > -- ------------------------------------------------------------ Kent Quirk I'm making a game about global warming. Game Architect Track the progress at: CogniToy http://www.cognitoy.com/meltingpoint |