I have an array defined in a file and in another I have to use it, for e.g-
/* a.c - defines an array */
int a[] = {1,2,3,4,5,6,7,8,9};
/* b.c - declare
If you want your array size to be accessible as a compile-time constant, then you have no other choice but to specify array size explicitly in the extern
declaration of the array
extern int a[9];
In this case it becomes your responsibility to make sure that array size is consistent between the extern
declaration and definition. You can use a manifest constant for that, but still it is going to be your responsibility to make sure that the number of initializers between the {}
and the declared size are the same.
If you don't care to have the array size as a compile-time constant, then you can do what Mark Wilkins suggests in his answer.