This is not a bug.
In ISO standard compliant C the structures namespace
must be prefixed by the 'struct' keyword, while in C++ a structure definition is automatically inserted in the global namespace.
You should modify your source as follows:
struct str1
{
int i;
float f;
};
struct str2
{
char c;
struct str1 st1; //prefix the 'struct' namespace
};
Or, as alternative, to keep the C++ style you can 'typedef' your structure definition. When using 'typedef' in a definition the name of the defined type is saved in the global namespace:
typedef struct str1
{
int i;
float f;
} str1;
struct str2
{
char c;
str1 st1; //str1 is defined in global namespace now
};
Using non fully standard compliant compilers, as MSVC, people get accustomed to the wrong behavior.