我在旧文件中看到了一些代码。
void (*const m_exec[N_EXECS])(void) =
{
#define PROCESS_DEF_TIMED(name) name, // defines macro for use in proclist.h
#define PROCESS_TIMED // define switch for section in proclist.h
#include "proclist.h"
#undef PROCESS_TIMED // undefine switch
#undef PROCESS_DEF_TIMED // undefines macro
};
我无法理解这段代码的含义。这是一个声明和函数定义在一起的函数指针吗?但是,如果我尝试像下面这样声明类似的函数指针,就会出现编译错误。
void (*voidFptr)(void) =
{
printf("Hello\n");
}
此处的#define是什么?我不确定它为什么在函数内部出现。