I let gcc compile the following example using -Wall -pedantic:
#include
int main(void)
{
printf(\"main: %p\\n\",
This whole idea is indeed non-portable, since some systems use different sized pointers to code and data.
What you really need is platform-specific knowledge of how big a function pointer is, and a cast to an integral type of that size. Unfortunately, I don't think anyone has standardized a intfuncptr_t analagous to intptr_t which can hold any data pointer.
As R. notes in his answer, you can always treat the pointer as an array of (possibly signed or unsigned) char, this way you don't need any integral type of the correct size.