Compiler Error C2208

'type' : no members defined using this type

An enumeration, structure, or union was defined without any members. This is an error only when compiling for C++ with the ANSI compatibility option (/Za).

This error can be caused by porting C code using nested structs to C++. Rewriting the code to use C++ mechanisms will eliminate this error. The following example shows C and C++ style structs. Note that the first C struct, if compiled for C++, declares a nested struct, Struct::ToBeIncluded, which is not the same as ::ToBeIncluded.

struct ToBeIncluded {
    int i;
};

#ifndef __cplusplus
struct Struct {     //C struct defined using /Ze extensions
    float x;
    struct ToBeIncluded;     // MS-C style struct injection
    float y;
};                           // error under /Za ANSI compatibility
#else
struct Intermediate {        // revised C++ struct
    float x;
};

struct Struct                // C++ style
    :   public Intermediate,
        public ToBeIncluded
{
    float y;
};                           // Always OK for C++
#endif