Tuesday, September 02, 2008

Un named structures and VS8

With two un-named structures , the linker on Windows has thrown the following error

unnamed_struct.obj : fatal error LNK1179: invalid or corrupt file:
duplicate COMDAT '??1@@QAE@XZ'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual
Studio 8\VC\BIN\link.EXE"' : return code '0x49b'
Stop.

The above is observed even with the varying number of struct members.

Known Issue: If two unnamed structs both declare a method with the same signature
and both are referenced, the compiler generates the same signature for both methods.
The linker then flags the .obj file as invalid due to duplicate COMDAT records
(More about this issue here)

The solution to this problem is, not to use more than one un-named structures

No comments: