Will a void* always have the same representation as a char*?

前端 未结 2 1115
我寻月下人不归
我寻月下人不归 2020-12-20 11:01

Will a void* always have the same representation as a char* ?

Details:

I want to work with a variadic function tha

相关标签:
2条回答
  • 2020-12-20 11:30

    It's specifically allowed to access a void* argument using va_arg(args, char*) and vice versa, not just for the null pointer.

    See also http://en.cppreference.com/w/cpp/utility/variadic/va_arg

    0 讨论(0)
  • 2020-12-20 11:46

    C11, §6.2.5, ¶28 (draft N1570) says:

    A pointer to void shall have the same representation and alignment requirements as a pointer to a character type. 48) Similarly, pointers to qualified or unqualified versions of compatible types shall have the same representation and alignment requirements.

    (emphasis mine).

    0 讨论(0)
提交回复
热议问题