#include
#include
#include
int main()
{
struct emp
{
struct address
{
int a;
The reason the warning is displayed is that the first excerpt is not proper C - it has a constraint violation that a standards-compliant C compiler must produce a diagnostisc message for. It violates the C11 6.7.2.1p2:
Constraints
- A struct-declaration that does not declare an anonymous structure or anonymous union shall contain a struct-declarator-list.
Meaning that it is OK to write
struct foo {
struct {
int a;
};
};
since the inner struct
declares an anonymous structure, i.e. it is not named.
But in your example the struct address
has a name - address
- and therefore it must have a declarator list after the closing brace - declarator list being for example a1
as in your example, or more complex foo, *bar, **baz[23][45]
.