Oct 7, 2021 at 10:49pm UTC
Hi all -
I have this defined in a source file:
const char *TASK_TAGS[TASK_ENUM_NBR_IDS] =
{
"Flash",
"HttpServer",
"I2dApp",
"Iob",
"Wifi",
};
and declared in a header file:
extern const char *TASK_TAGS[TASK_ENUM_NBR_IDS];
When I try to use it in another source file (like this):
static const char *TAG = TASK_TAGS[TASK_ID_HTTPSERVER];
I get an error: initializer element is not constant.
What am I doing wrong here? Thanks...
Oct 8, 2021 at 1:15am UTC
can't reproduce, provide a testcase
(don't narrate your code, just show it)
Oct 8, 2021 at 2:18am UTC
no need for pointers, simpler to say:
const char blah[5][20]=
{"Flash",
"HttpServer",
"I2dApp",
"Iob",
"Wifi"};
and to use it elsewhere just extern it like anything else. I prefer to make a little function that exposes it rather than extern it, but that is your call.