I have definition and declaration of constant int:
a.h
extern const int w ;
a.c
const int w = LV_HOR_RES_MAX / 2
Trying to use it in another c file:
b.c
typedef struct picLabing
{
int width;
} aaa;
typedef struct {
aaa temperatures;
}settings_typ;
settings_typ a =
{
.temperatures = { .width = w },
}
Got error while build:
Error initializer element is not constant
Why I'm getting this error? According to my understanding w is declared as constant .
Everything works fine when I define and declare w in the same b.c file. Why?