The reason the compiler shows a warning is because it does not see the name of the variable of type address that you defined for the emp structure, even if you do declare something using address on the next line, but I think the compiler is not smart enough to understand this.
As you have shown, this causes a warning:
struct emp { struct address {};
But not this:
struct emp { struct address {} a1;
Or that:
struct address {}; struct emp { struct address a1;
struct emp {} does not display any warnings, because this statement is not inside the structure detection block. If you put it inside one of them, then the compiler will also show a warning. The following are two warnings:
struct emp { struct phone {}; struct name {}; };
juan.facorro
source share