difference between int* member[0] and int member[0] in struct

struct A {
  int zero_member[0];
  int other;

struct B {
  int* zero_member_ptr[0];
  int other;

printf("%d %d", sizeof(struct A), sizeof(struct B));


4 8

Why the difference?

In reality I’m using this with Android NDK, and I’ve tested it at Compiler Explorer without any flag. So, if this is not standard ISO C program, this problem should have no standard answer.

>Solution :

"Why the difference?"

Likely due to padding to meet pointer alignment requirements – even if it is size 0.

Leave a Reply Cancel reply