I have to define a large array (lookup table) in a code. It contains 256 elements and takes nearly 1 computer screen.
There are two functions that are using this array. I want to define this array under functions, so I could access them very quickly during development.
But if I try to do it inside one file, compiler will give "Undeclared identifier" errors around functions - because they use array.
So, I must put the functions and the array to separate files.
Here is the structure of my program:
main.cpp:
#include "lookup.h"
...uses two functions...
-
lookup.h:
#ifndef SubMaster_lookup_h
#define SubMaster_lookup_h
void func1(void);
void func2(void);
char LookupTable[][3]={ "00", "01", "02" "03", "04", "05", "06", "07", "08", "09",
"0a", "0b", "0c", "0d", "0e", "0f", "00", "01", "02" "03", "04", "05", "06", "07",
"08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", and so on...}
-
lookup.cpp:
#include "lookup.h"
void func1() {
...body of func1...
}
void func2() {
...body of func2...
}
The following structure gives me "ld: duplicate symbol _LookupTable" during build. Is there any way to change the structure, so it will not give errors?