gpt4 book ai didi

c++ - 错误: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]

转载 作者:行者123 更新时间:2023-11-30 21:17:04 27 4
gpt4 key购买 nike

出现错误:

error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive] on g++

在以下代码上:

void* func(void *s)
{
int i = 0;
int self = (int *)s;
printf("Thread Entered: %d\n", self);

sm.lock(self);

// Critical section (Only one thread
// can enter here at a time)
for (i=0; i<MAX; i++)
ans++;

sm.unlock(self);
}

最佳答案

您需要将 int self = (int *)s; 更改为 int self = *((int *)s);int * self = (int *)s;

关于c++ - 错误: invalid conversion from ‘int*’ to ‘int’ [-fpermissive],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47644509/

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