"Steven Woody" <na********@gmail.com> wrote:
void ( * on_data_receive_of_ph ) ( const short line, const uint8_t c );
...
printf( "addr of function = %x\n", (void*)on_data_receive_of_ph )
--- (*)
the line of (*) always causes a compiler warning:
warning: unsigned int format, pointer arg (arg 2)
That's because, surprise, you have used a format (%x) which expects you
to pass an unsigned int, but what you actually pass is a pointer. If you
want to print a void *, use %p instead.
Note that even then your code will still cause undefined behaviour. You
can only convert pointers to object or incomplete types to void *, not
function pointers. The behaviour of the cast (void *)<function pointer>
is not defined by ISO C. If it happens to work on your compiler, fine
and good; but it's not portable, and may not be reliable.
Richard