我使用#define
来调用一个函数,并得到以下gcc错误:
第"101"话指令
下面是定义指令:
#define HASH(STRING_VALUE) (lookup_hash(STRING_VALUE))
功能实现:
static inline uint32_t lookup_hash(const char *str)
{
uint32_t hash = 5381;
int32_t c;
while ((c = *str++))
{
hash = ((hash << 5) + hash) + c;
}
return hash;
}
函数调用示例:
static const asr_handlerTree_t asr_LT_nwk_orders[]=
{
{HASH("link"), NULL, asr_link_funct},
{HASH("unlink"), NULL, asr_unlink_funct},
// Used at runtime to determinate table limit, keep at table tail
{(uint32_t) 0, NULL, NULL}
};
GCC编译器为什么会提出这个问题,因为指令调用只应该在前处理时被函数取代?
更新:在应答反馈后添加 struct 声明:
typedef struct _asr_handlerTree_type_
{
const uint32_t hashedIntent_u32;
const asr_handlerTree_t * branchs;
const funct_t Func;
} asr_handlerTree_t;