I've declared a global structure in supportFunctions.h:
...
struct historyStruct {
char historyArray[HISTORY_DEPTH][COMMAND_LENGTH];
int currentSize;
int totalCommandsExecuted;
};
extern struct historyStruct history;
...
And I've defined history
in main.c
:
int main(int argc, char* argv[])
{
struct historyStruct history;
history.currentSize = 0;
history.totalCommandsExecuted = 0;
...
historyCommand.c
, a file where I want to use history
, includes supportFunctions.h
but for some reason isn't detecting my global struct history
. Whenever I try to use it I'm getting an undefined reference
error. Is the process I described the way to create a global struct? Or am I missing something?