C language in Visual studio Struct within a struct: error CXX0025: Error:operator needs class/struct/union
Hopefully someone can tell me what I'm doing wrong.
I have a struct that contains a struct. When I try to access properties of the struct contained
within the first struct, I receive an error:
CXX0025: Error:operator needs class/struct/union
From what I can tell this is proper syntax in C; however, there must be something specific
to the Microsoft C++ compiler that I'm not getting.
I created a win32 project in visual studio 2008.
NB. Although you can define structs in a function the semantics are somewhat different to defining them outside a function (the normal place for you to put them).
Well, the specifics for using local classes/structs are part of the C++ standard; however, VS2008 is a little bit loose with this. In this case, your original code should have compiled (and does in gcc) but my experience of Visual Studio is that it doesn't play well with local classes/structs and the reasons for using them are rarely enough to justify the confusion they cause to others or the compiler.
NB. Although you can define structs in a function the semantics are somewhat different to defining them outside a function (the normal place for you to put them).
Open in new window