I have a function int rt_task_start (RT_TASK *task, void(*task_func)(void *arg), void *arg) where in the second argument I pass a function with an argument.
int rt_task_start (RT_TASK *task, void(*task_func)(void *arg), void *arg)
rt_task_start(&demo_task1, demo, 1);
rt_task_start(&demo_task1, demo(&val), 1);
error: invalid use of void expression
int val = 0;
rt_task_start(&demo_task1, demo(val), 1);
Warning passing argument 1 of 'demo' makes pointer from integer without a cast
int *val; *val = 0;
I can’t understand what I should pass as a pointer to a void. This gives me an error. Any idea please!
void (*task_func)(void *arg);
task_func , void * .
task_func
void *
, rt_task_start, . , void * , . , , - & .
rt_task_start
&
int arg = 4; // both calls are equivalent rt_task_start(&demo_task1, demo, &arg); rt_task_start(&demo_task1, &demo, &arg);
, (1) . :
int rt_task_start (RT_TASK *task, void(*task_func)(void *arg), void *arg); int val = 1; rt_task_start(&demo_task1, demo, &val);
, , - , C. , , , , ( , ). , .
, :
int i=1; rt_task_start(&demo_task1, demo, (void*) &i);
, , - , , , rt_task_demo. '1' 'rt_task_demo',
int ii = *(int*) arg;
Source: https://habr.com/ru/post/1534044/More articles:How to get the current system year in Prolog as a number - prologhow to override mongoose plugin function? - node.jsscrollable gridview with fixed search string in datagrid using wpf - wpfТестирование строки и целочисленных массивов с помощью ввода пользователем - javaCapturing the screen selected by the current form in WPF? - c #Rails 4 loads multiple tables - ruby | fooobar.comDoes CQRS read ORM side or pure ADO.NET? - c #C ++: converting WCHAR to LPCWSTR - a real working example - c ++Invalid single table inheritance type .. not a subclass - ruby-on-railsHow to obfuscate lua code? - luaAll Articles