Re: VS 2003 generating duplicate COMDAT for template instantiation?

"Mat Noguchi (BUNGIE)" <[email protected]> Sat, 12 May 2007 12:15:52 -0700
Newsgroups gmane.games.devel.windows
Message-ID <4AAE6D312A2DC64CBEEA550C4417B08B112120FB28@NA-EXMSG-C109.redmond.corp.microsoft.com>
Well, if that's the case... do you have anything that is a function local static function? I've hit a similar problem when trying to generate a unique class static function per inline function. No valid workaround either.

MSN
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jon Watte
Sent: Saturday, May 12, 2007 10:35 AM
To: Game Development for MS Windows
Subject: Re: [GD-Windows] VS 2003 generating duplicate COMDAT for template instantiation?

Hmm. Well, the error in question here is that the compiler seems to emit
two instantiations of the same template, in the same object file,
without marking them as merge-able. Thus, the linker claims (rightly)
that the .obj file is bad.

I can try to chop it down and feed it to GCC 4, but given that the
syntax is, I think, correct, I don't have high hopes. I think this is a
MSVC specific problem. Anyway, I'll report back.

Cheers,

          / h+


Matt J wrote:
> 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
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
>> Archives:
>> http://sourceforge.net/mailarchive/forum.php?forum_id=555
>>
>>
>
>
>

-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=555

-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=555