Re: How to print pointer to function?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019-12-12 10:21:16 +0100, Josef Wolf wrote:
> I would like to print the pointer to a function for debugging purposes.
> 
> But I keep getting a warning:
> 
>   ttt.c: In function 'insert_transfer':
>   ttt.c:7:37: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
>       7 |     printf ("lost transfer %p\r\n", (void*)rdyfunc);
> 
> Is there any way to get rid of this warning?

The only portable & standard way I can think of is to store the
function pointer as an array of unsigned char, and output the
contents of this array. Note that there are no aliasing issues.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux