Standard type for code pointers?

Bruce Evans bde at
Wed Apr 20 22:42:55 PDT 2005

On Wed, 20 Apr 2005, Erik Trulsson wrote:

> On Wed, Apr 20, 2005 at 08:34:18AM -0700, Marcel Moolenaar wrote:
>> On Apr 20, 2005, at 5:41 AM, Joseph Koshy wrote:
>>> I'm looking for a standard type that is defined to have at least
>>> as many bits as needed to hold a pointer to code.  What would
>>> that be?
>> intptr_t is probably what you want.
> Except that intptr_t need only be large enough to hold an object
> pointer.  This is not necessarily enough to hold a function pointer.
> The only standard types that are guaranteed to be able to hold a
> function pointer are other function pointers.

There is no standard type for this, but there FreeBSD has the following:

uintfptr_t: like uintptr_t except for function types
fptrdiff_t: like ptrdiff_t except for function types

These are defined in <machine/profile.h> and are supposed to be used in
all profiling code written in C in the last 10 years (gprof is much
older and doesn't use them except via their use in <sys/gmon.h>; gprof
converts almost everything to floating point anyway, and is probably
horribly broken if the function address space isn't flat (but a non-flat
space could be flattened for it)).


More information about the freebsd-standards mailing list