gpt4 book ai didi

c - 为什么比较空函数指针结果为 "invalid operands to binary =="

转载 作者:太空宇宙 更新时间:2023-11-04 06:04:33 24 4
gpt4 key购买 nike

有人可以向我解释为什么下面的代码会出现“二进制操作数无效 ==”错误吗?

typedef int (*func_t)(int);
#define NO_FUNC ((func_t) 0)
struct {
const char *name;
func_t func;
} table[] = { {"func1", NO_FUNC} };

if (table[0] == NO_FUNC) { // invalid operands to binary ==

}

最佳答案

并且您应该在结构中引用正确的成员:

if (table[0].func == NO_FUNC)

关于c - 为什么比较空函数指针结果为 "invalid operands to binary ==",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12869081/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com