Re: [GD-Windows] VS 2003 generating duplicate COMDAT for template instantiation?
Brought to you by:
vexxed72
From: Matt J <mjo...@gm...> - 2007-05-12 06:19:43
|
I'm curious where Field is defined, and if the compiler can understand it is a type. Im thinking something like this might work... but my templates are rusty template<class T> { typedef typename T* FieldPtr } Container; And a pointer being passed as: Container<pit::FloatTriple>(core_->ambientlight_[l]) The other template being template<class Field, class C = Container<Field> > class FieldAccessor { typedef C::FieldPtr TypePtr; FieldAccessor(TypePtr &t) :MyTypePtr(t) {} // accessor returns &MyTypePtr TypePtr &MyTypePtr; } Anyway, good luck :p Matthew > > 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. > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > -- ----- Matt Johnson http://otowngraphics.blogspot.com |