Reputation: 1501
I have a log function which takes a parameter, which prints out the name of some HW
logEvent("LOG THIS HW select = %s", NAME[selection]);
To determine what to print I have:
const char* NAME[] =
{
"A"
"B"
}
This was in the header but then I got multiple implementations problems, I want this to be accessed by many files. How can I put this kind of data in a header?
Upvotes: 0
Views: 70
Reputation: 66371
You put a declaration in the header:
extern const char* NAME[];
and put the definition in one cpp file:
const char* NAME[] = {"A", "B"};
Upvotes: 3
Reputation: 234715
Adjust logEvent
so selection
is passed as a parameter. You can then keep the string table local to that function.
Upvotes: 3