There is no standard way of archiving what you seek. All possible solutions either involve system dependent ways to resolve function addresses to their names (and even that does not necessarily always work) or changing the func_array like so:
struct {
func_pointer_t func;
const char * name;
} func_array[] = {
{ func_1, "func_1" },
{ func_2, "func_2" },
{ func_3, "func_3" },
...
};
you can use a macro, to ease the job:
#define FUNC_DEF(func) { func, #func },
and then use it like this:
struct {
func_pointer_t func;
const char * name;
} func_array[] = {
FUNC_DEF(func_1)
FUNC_DEF(func_2)
FUNC_DEF(func_3)
...
};
So, if this is an option for you, you got your solution. If not, you gonna have to tell, what system you're targeting.
More C++ish solutions exist - like the std::map solutions hinted to by Govind Parmar where you could iterate and take the key <-> value pair.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…