Are all data pointers the same size in one platform for all data types?

前端 未结 8 850
太阳男子
太阳男子 2020-11-22 16:33

Are char*, int*, long* or even long long* of same size (on a given platform)?

8条回答
  •  囚心锁ツ
    2020-11-22 17:15

    Note what the C standard says - as quoted by John Bode. Note, too, that the C standard says nothing about the sizes of pointers to functions at all.

    The POSIX standard lays down some extra requirements:

    2.12.3 Pointer Types

    All function pointer types shall have the same representation as the type pointer to void. Conversion of a function pointer to void * shall not alter the representation. A void * value resulting from such a conversion can be converted back to the original function pointer type, using an explicit cast, without loss of information.

    Note: The ISO C standard does not require this, but it is required for POSIX conformance.

提交回复
热议问题