This topic has not yet been rated - Rate this topic

Compiler Warning (level 2) C4099

'identifier' : type name first seen using 'objecttype1' now seen using 'objecttype2'

An object declared as a structure is defined as a class, or an object declared as a class is defined as a structure. The compiler uses the type given in the definition.

The following sample generates C4099.

// C4099.cpp
// compile with: /W2 /c
struct A;
class A {};   // C4099, use different identifer or use same object type
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Useless warning ?
I have a big problem with this warning: According to the C++ standard, a struct is no different from a class (except for default visibility, which only has some impact for the class definition), and the following code should compile with no warnings:
class T;
struct T;
class T {};

I know that, once upon a time, VC++6.0 used a different name mangling for classes and struct, which created some link-time problem. I don't know if this bug has been corrected, and the document associated with this warning does not explicit if it is related to this bug or not.
Advertisement