I have many different 3 axis sensors I am writing test code for. In the C files for each of them, I have the same char string defined:
char axis[3][8] = {"X", "Y", "Z"}
which I use when I “for” loop results to print the axis that is failing like this:
DEVICETEST_LOG("%s Failed %s axis for Min range\n",device_name[DUT], axis[i]);
I was thinking to save some space I could define a character string array in a header file to use all over the place.
I have tried a number of things, but I can’t seem to get an array of strings defined in my header file that I can iterate through to pass a compile.
In order to avoid linker errors, you have to declare your array as
externin a header file, and then define the array once in one of your code modules.So for instance:
then in another code module somewhere: