#include <stdio.h> struct s {int;}; int main() { printf("Size of 'struct s': %i\n", sizeof(struct s)); return 0; }
The Microsoft C compiler (cl.exe) does not want to compile this code.
error C2208: 'int' : no members defined using this type
The GNU C compiler (gcc -std = c99) compiles this code ...
warning: declaration does not declare anything
... and displays the result:
Size of 'struct s': 0
This means that struct s in gcc is a full type and cannot be overridden.
Does this mean that the full type can have zero size?
Also, what does a declaration does not declare anything mean if this declaration declares a complete structure?
Here is the proof that struct s is the full type in (gcc -std = c99).
#include <stdio.h> struct s {int;}; struct S { struct ss; // <=========== No problem to use it }; int main() { printf("Size of 'struct s': %i\n", sizeof(struct s)); return 0; }
source share