c - sizeof Pointer differs for data type on same architecture -
i have been going through posts , noticed pointers can different sizes according sizeof
depending on architecture code compiled , running on. seems reasonable plenty me (ie: 4-byte pointers on 32-bit architectures, 8-byte on 64-bit, makes total sense).
one thing surprises me size of pointer can different based on info type points to. have assumed that, on 32-bit architecture, pointers 4-bytes in size, turns out function pointers can different size (ie: larger have expected). why this, in c programming language? found article explains c++, , how the programme may have cope virtual functions, doesn't seem apply in pure c. also, seems utilize of "far" , "near" pointers no longer necessary, don't see entering equation.
so, in c, justification, standard, or documentation describes why not pointers same size on same architecture?
thanks!
the c standard lays downwards law on what's required:
all info pointers can converted
void*
, without loss of information. all
struct
-pointers have same representation+alignment , can converted each other. all
union
-pointers have same representation+alignment , can converted each other. all character pointers , void pointers have same representation+alignment.
all pointers qualified , unqualified compatible types shall have same representation+alignment. (for illustration unsigned / signed versions of same type compatible)
all function pointers have same representation+alignment , can converted other function pointer type , again.
nothing more required. commission arrived @ these guarantees examining current implementations , machines , codifying many guarantees could.
on architectures pointers naturally word pointers instead of character pointers, info pointers of different sizes. on architectures different size code / info spaces (many micro-processors), or additional info needed invoking functions (like itanium, though hide behind data-pointer), code pointers of different size info pointers.
c pointers sizeof