Skip to content
Next Next commit
Remove implicit conversions between function and data pointers
IAR generates errors Pe144 'a value of type "int32_t (*)(int32_t)" cannot
be used to initialize an entity of type "void *" and Pe513 'a value of
type "int32_t (*)(int32_t)" cannot be assigned to an entity of type
"void *"'.

Also, when citing the name of a specific function, there's no need to use
the '&' operator before the symbol - it's already typed as a function
pointer.
  • Loading branch information
Ben Avison committed Sep 13, 2022
commit cf23c92e8465a3a5b82e9c251205baa288b62ba3
9 changes: 4 additions & 5 deletions multicore/multicore_runner_queue/multicore_runner_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

typedef struct
{
void *func;
int32_t (*func)(int32_t);
int32_t data;
} queue_entry_t;

Expand All @@ -31,8 +31,7 @@ void core1_entry() {

queue_remove_blocking(&call_queue, &entry);

int32_t (*func)() = (int32_t(*)())(entry.func);
int32_t result = (*func)(entry.data);
int32_t result = entry.func(entry.data);

queue_add_blocking(&results_queue, &result);
}
Expand Down Expand Up @@ -78,7 +77,7 @@ int main() {

multicore_launch_core1(core1_entry);

queue_entry_t entry = {&factorial, TEST_NUM};
queue_entry_t entry = {factorial, TEST_NUM};
queue_add_blocking(&call_queue, &entry);

// We could now do a load of stuff on core 0 and get our result later
Expand All @@ -88,7 +87,7 @@ int main() {
printf("Factorial %d is %d\n", TEST_NUM, res);

// Now try a different function
entry.func = &fibonacci;
entry.func = fibonacci;
queue_add_blocking(&call_queue, &entry);

queue_remove_blocking(&results_queue, &res);
Expand Down