J'ai deux structures définies comme suit:
struct EmptyStruct{
};
struct StructEmptyArr{
int arr[0];
};
int main(void){
printf("sizeof(EmptyStruct) = %ld\n", sizeof(EmptyStruct));
printf("sizeof(StructEmptyArr) = %ld\n", sizeof(StructEmptyArr));
return 0;
}
Compilé avec gcc (g ++) 4.8.4 sur Ubuntu 14.04, x64.
Sortie (pour gcc et g ++):
sizeof(EmptyStruct) = 1
sizeof(StructEmptyArr) = 0
Je peux comprendre pourquoi sizeof(EmptyStruct)
est égal à 1
mais ne peux pas comprendre pourquoi sizeof(StructEmptyArr)
est égal à 0
. Pourquoi y a-t-il des différences entre deux?