I have this code
struct counter_info {
atomic_t counter;
char *name;
} __attribute__((packed));
extern struct counter_info __start_counters;
extern struct counter_info __stop_counters;
#define __DOSOMETHING(F) \
do{ \
static struct counter_info __counter_info_##F \
__attribute((__section__("counters"))) \
__attribute((__used__)) = { \
.name = #F, \
}; \
atomic_set(&__counter_info_##F.counter, 0); \
\
}while(0)
I call this macro as this:
__DOSOMETHING(FOO)
And I'd like to access __counter_info_##F
from this other code
#define __DOSOMETHINGELSE(F) \
do{ \
atomic_inc(&__counter_info_##F.counter); \
}while(0)
with __DOSOMETHINGELSE(FOO)
but I get an undeclared error from the compiler. Why is that? Can it be done?
EDIT:
The exact error is
error: ‘__counter_info_FOO’ undeclared (first use in this function)
note: in expansion of macro ‘__DOSOMETHINGELSE’