C
Christopher Bohn
It looks like the c++ source for a single object file can not contain
more than one anonymous class that derives from a base class. When I
attempted to do this, the linker failed with the following error:
fatal error LNK1179: invalid or corrupt file: duplicate COMDAT
'??0__unnamed@@QAE@XZ'
The "??0__unnamed@@QAE@XZ" symbol undecorates to "public: __thiscall
__unnamed::__unnamed(void)" so I think the compiler is using the same
class name for each anonymous class. When the compiler then synthesizes
a default constructor for each class, it winds up generating two
functions with the same name.
Here is some example code:
#include <exception>
class : public exception
{
} anonymous1;
class : public exception
{
} anonymous2;
This was easy to work around by giving each previously anonymous class a
name but shouldn't the compiler generate unique class names for them?
more than one anonymous class that derives from a base class. When I
attempted to do this, the linker failed with the following error:
fatal error LNK1179: invalid or corrupt file: duplicate COMDAT
'??0__unnamed@@QAE@XZ'
The "??0__unnamed@@QAE@XZ" symbol undecorates to "public: __thiscall
__unnamed::__unnamed(void)" so I think the compiler is using the same
class name for each anonymous class. When the compiler then synthesizes
a default constructor for each class, it winds up generating two
functions with the same name.
Here is some example code:
#include <exception>
class : public exception
{
} anonymous1;
class : public exception
{
} anonymous2;
This was easy to work around by giving each previously anonymous class a
name but shouldn't the compiler generate unique class names for them?