Because in C ++, the struct you define is named S , and in C, it is struct S (so you often see the typedef struct used in C code). If you want to change the code to the following, you will get the expected results:
char S[13]; void fun() { typedef struct tagS { int v; } S; int v1 = sizeof(S); }
source share