I have two files, main.c
and other.h
. I declare a few global variables in main.c
, and most of them are fine. I can say extern whatever
in other.h
and access those variables. However, I defined a struct like this (in main.c
):
struct LSA {
int myID;
int seqNum;
int neighborID[256];
int costs[256];
} local_LSA[256];
And when I try to access it in other.h
like this
extern struct LSA local_LSA[256];
I get this error message
other.h:27:19: error: array type has incomplete element type ‘struct LSA’
extern struct LSA local_LSA[256];
I've been playing around with for a while, but... I appreciate any help anyone is able to provide!
The structure type needs to be defined before any instances of it can be created.
You need to move the struct definition into other.h before local_LSA
is defined.