I compiled these codes in MSVC:
int a=sizeof(struct{char c;});
and
int b=((struct{char c;} *)0,0);
and
printf("%p",(struct{char c;} *)0);
As C codes, they can pass compiling, with a warning (warning c4116: unnamed type definition in parentheses. If you give a name, it's "warning c4115: "Whatever" : named type definition in parentheses");
As C++ codes, they are compiled with a bunch of errors.
My questions are:
1. In C, are type definitions in parentheses valid? Why do I get that warning?
2. In C++, are type definitions in parentheses valid?
EDIT :
3. Why?
In C:
and
are both valid expressions. An implementation is free to issue an additional informational diagnostic messages for valid C code.