Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading 将结构作为P线程参数传递Linux无法转换为指针类型_Multithreading_Pthreads_Linux Device Driver - Fatal编程技术网

Multithreading 将结构作为P线程参数传递Linux无法转换为指针类型

Multithreading 将结构作为P线程参数传递Linux无法转换为指针类型,multithreading,pthreads,linux-device-driver,Multithreading,Pthreads,Linux Device Driver,我正在尝试将此结构传递给pthread // this is my struct /// typedef struct { HCORE BM_cores[0]; int total_cores; } BM_PARAMS; BM_PARAMS BM_Dat; 在Pthreadcreate,我收到一个错误。。无法转换为指针类型 int Start_monitor(void) { int RETVAL=0; RETVAL = pthread_create(&monitor_thread

我正在尝试将此结构传递给pthread

// this is my struct ///

typedef struct
{
HCORE BM_cores[0];
int total_cores;
} BM_PARAMS;

BM_PARAMS BM_Dat;
在Pthreadcreate,我收到一个错误。。无法转换为指针类型

int Start_monitor(void)
{
int RETVAL=0;
 RETVAL = pthread_create(&monitor_thread, NULL, Get_Monitor_Data,(void*)BM_Dat);
 if(RETVAL !=0)
 {
  printf("Error Starting Thread \n");
 }

 return 0;
 }
我收到一个错误,无法转换为指针类型 我正在使用eclipse编码这个

。。。声明变量
BM_-Dat
具有类型
BM_-PARAMS
,这是一种结构类型。这没什么错

此线程函数摘录

。。。显示它希望其参数是指向
BM_参数的指针。这也没什么错

但是调用
pthread\u create()

。。。正在尝试将
BM_Dat
转换为指针,这既没有意义也不可能。您似乎想做的是传递变量
BM\u dat
的地址。也就是说,您希望:

 RETVAL = pthread_create(&monitor_thread, NULL, Get_Monitor_Data,(void*)BM_Dat);

无需将
&BM_Dat
强制转换为type
void*
,因为所有对象指针都可以自动转换为type
void*
(并返回),而无需转换。更一般地说,用于算术以外的其他目的的强制转换具有不好的代码气味。它们通常要么是不必要的,要么是错误的。

您能公布准确的错误吗?该错误可能会告诉您哪些变量无法转换为指针类型。注意:尽管通常发音类似于“pea-thread”,好像“p”是一个单独的首字母,“pthread”实际上是一个单词。
typedef struct
{
HCORE BM_cores[0];
int total_cores;
} BM_PARAMS;

BM_PARAMS BM_Dat;
void *Get_Monitor_Data (void *BM_Dat) // Bus Monitor Thread
{
BM_PARAMS*monitor_params;
int no_of_cores=0;
monitor_params = (BM_PARAMS *) BM_Dat;
 RETVAL = pthread_create(&monitor_thread, NULL, Get_Monitor_Data,(void*)BM_Dat);
 RETVAL = pthread_create(&monitor_thread, NULL, Get_Monitor_Data, &BM_Dat);