I am refactoring a c++ code and there is something I cannot understand. The code is declaring a set of arrays in a header file then include that header file in source files when needed. All arrays are "const unsigned char[]" except one which is "const char *[]" array. The latter is surrounded with an #ifdef SOMETHING. If SOMETHING is not defined code is built successfully, otherwise I got linker errors of multiple definitions for this "char *[]" only.
As a fix, I can eliminate those linker errors by adding "static" to "const char* XX[3] = {"X", "Y", "Z"}". This will keep the definition specific to the translation unit.
However, what I cannot understand why "multiple definitions" errors only occur with "const char* []" array and not with the others "const unsigned char[]" despite they are not preceded by a "static" keyword? Could someone explain that to me please?
const char* XX[3] = {"X", "Y", "Z"};is a definition.const, not the*or theunsigned.const unsigned char[]is a const array,const char*[]is a non-const array (of const pointers).