【发布时间】:2020-10-07 02:53:57
【问题描述】:
对于我正在编写的一些代码,我正在尝试获取线程,但我不断收到错误消息。我正在用 Visual Studio 代码在 linux 上编程。
这是代码:
void* start(void *s) {
int me = (int*)s;
//int me = pthread_self();
printf("Entered: %d\n", me);
Lock(me);
printf("TEST 1");
for (int i = 0; i<MAX; i++) ans++;
printf("TEST 2");
Unlock(me);
printf("TEST 3");
return NULL;
}
pthread_create(&thread1, NULL, start, (void*)0);
pthread_create(&thread2, NULL, start, (void*)1);
pthread 创建在 main 方法中。我得到的错误:
错误:从“int*”到“int”的无效转换[-fpermissive] 49 |诠释我=(诠释*)s; | ^~~~~~~ | | |整数*
【问题讨论】: