c: size of void*

前端 未结 2 668
隐瞒了意图╮
隐瞒了意图╮ 2021-02-01 16:02

I\'m a bit confused with a void* pointer in C. Especially after reading this question: Is the sizeof(some pointer) always equal to four?, where one person says there is no guara

2条回答
  •  名媛妹妹
    2021-02-01 16:44

    Only data pointers. void * can hold any data pointer, but not function pointers.

    Here is a C FAQ.

    void *'s are only guaranteed to hold object (i.e. data) pointers; it is not portable to convert a function pointer to type void *. (On some machines, function addresses can be very large, bigger than any data pointers.)

    As for the first part, yes, different types can have pointers of different sizes:

提交回复
热议问题