我正在尝试编译一些C代码,但我得到了这个错误
错误:无效的二进制操作数&;(具有"int"one_answers"pthread_t"{aka"struct<<"匿名>'}(
有问题的代码是
static void kill_mining(void)
{
struct thr_info *thr;
int i;
forcelog(LOG_DEBUG, "Killing off mining threads");
/* Kill the mining threads*/
for (i = 0; i < mining_threads; i++) {
pthread_t *pth = NULL;
thr = get_thread(i);
if (thr && PTH(thr) != 0L)
pth = &thr->pth;
thr_info_cancel(thr);
if (pth && *pth) <---- This is where it goes wrong
pthread_join(*pth, NULL);
}
}
我不知道C,所以我有点不知道如何解决这个问题。任何帮助都会得到通知。
感谢
编辑:代码来自https://github.com/ckolivas/cgminer它是cgminer.c文件。
给定
pthread_t *pth;
用解引用pth
值
if (pth && *pth)
是错误的。
pthread_t
是在sys/types.h
:中的POSIX下定义的
;sys/types.h>标题应至少定义以下类型:
. . . pthread_t Used to identify a thread. . . .
添加了警告
除了以下例外,所有类型都应定义为适当长度的算术类型:
. . . pthread_t . . .
将pthread_t
变量视为可以作为布尔表达式的一部分进行求值的对象是不恰当和错误的。