03-25-2008 07:09 AM
03-25-2008 09:29 AM
Hi,
You can pass a structure to a thread by using a void *.
example:
typedef struct
{
int a;
}MyStruct
ThreadFunc(void *)
{
memcpy(
}
03-25-2008 09:29 AM
Hi,
You can pass a structure to a thread by using a void *.
example:
typedef struct
{
int a;
}MyStruct
ThreadFunc(void *)
{
memcpy(
}
03-25-2008 09:29 AM
Hi,
You can pass a structure to a thread by using a void *.
example:
typedef struct
{
int a;
}MyStruct
ThreadFunc(void *)
{
memcpy(
}
03-25-2008 09:33 AM
|
![]() |
Sorry I hit tab and then the space bar and it posted. Hi, You can pass a structure to a thread by using a void *. example: typedef struct ThreadFunc(void *var) MyStruct tmp; } As an alternate to copy you can perform a type cast. |
03-25-2008 10:59 AM - edited 03-25-2008 11:00 AM
09-15-2010 09:13 AM
I know this thread is old, but I ran into an error and need a quick clarification.
I have this struct...
typedef struct{
int id;
int funcID;
} device_ref_table;
I want to do the following ThreadPoolFunctionCall and pass the struct as the pointer to void
device_ref_table drt;
CmtScheduleThreadPoolFunction(DEFAULT_THREAD_POOL_HANDLE,InstrumentFunctions,(void*)drt,NULL);
BUT, I get "Cast from 'device_ref_table' to 'pointer to void' is illegal
On the receiving end...
I have the following which may not be correct yet, since I keep changing it.
int CVICALLBACK InstrumentFunctions (void *functionData)
{
device_ref_table *drt = functionData;
I don't think I want to pass the address of the struct because if I make this same call twice with different values before the Callback function finishes, I believe I will have some issues.
If this can't be done, or if someone thinks its easier, should I pass a 2 variable integer array?
Thanks in Advance.
Nick
09-15-2010 09:26 AM
You must pass the address of the structure. As in:
CmtScheduleThreadPoolFunction(DEFAULT_THREAD_POOL_HANDLE,InstrumentFunctions,(void*)&drt,NULL);
This is compatible with your receiving code.
JR