I have a header constants.h
file, with the following declarations of an array variable:
extern storageCommandData storageCommands[];
The type of the array is defined elsewhere, and is not relevant to the question. In another source file (.c) I initialized the array like so:
#include "constants.h"
storageCommandData storageCommands[STORAGE_COMMAND_NUM] =
{
/*storageCommandData intilazation follows the
following template: {commandName, storageSize}*/
{".db", 1},
{".dw", 4},
{".dh", 2},
{".asciz", 0},
};
I tried to use these arrays in another source file (a different one than the one I define the arrays in), by including constants.h
.
However, when I try to use the variable storageCommands I get the following error message:
undefined reference to `storageCommands'
How do I fix the error?