In x.h
add:
extern size_t x_count;
In x.c
add:
size_t x_count = sizeof(X)/sizeof(x);
Then use the variable x_count
in your loop.
The division has to be done in the compilation unit that contains the array initializer, so it knows the size of the whole array.