Been a loooooong time since I’ve actually coded straight c (not even C++ but c) and I know how to use the extern keyword to share a variable between separate .c files, but what I can’t remember is how to share constant data between files?
For example, say I have this… (note, this is not c code (or if it is, its an accident) but rather pseudo-code to show what I want):
const char const * WEEKDAYS[] = {
"Sunday",
"Monday",
"Tuesday"
}
Now I’m trying to create an array of char pointers that point to the data. Again, this is constant data so I’d like to just define it in a header directly, but that’s where I can’t figure out how to do it, or if that isn’t how you should do it anyway and you should still declare it in the c file, then use extern in the header you include elsewhere.
Again, been a long time since I’ve had to deal with this thanks to the newer, more modern languages, but hoping you can help.
It’s the same as for variables:
Also you probably want
const char * const, notconst char const *which is invalid syntax.