[ SOLVED ]Table function pointers

Hi,
using Eclipse for ARM M4 code ok,

using PIO ARM M3 error code.

table saved functions poiters in flash,
void f01(uint32_t);
void f02(uint32_t);
uint32_t f03(void);

const uint32_t tablefunc[] = {(uint32_t*)&f01, // error with PIO
(uint32_t*)&f02,
(uint32_t*)&f03,

};

void (*ram_call)(uint32_t);

    ram_call	 = (uint32_t)  tablefunc[ 0 ]; //  call f01
    ram_call( 1); ok

using PIO not compiling.

thanks,
Carlos

You’ve declared an array of uint32_t elements but then put uint32_t* elements in it. Type error. Either change the type to uint32_t* or cast each element to (uint32_t).

2 Likes

to
const uint32_t tablefunc = {
(uint32_t)&f01,
(uint32_t)&f02,
(uint32_t)&f03,

};

runing ok

thanks,
Carlos.

1 Like