const void * 与 void const *

问题描述 投票:0回答:1

这个问题我得到了不同的答案。我知道其他数据类型的顺序并不重要/只是根据偏好(例如 const char * 和 char const *)。

不确定这是否同样适用于 void *: const void * == void const *?

c pointers constants
1个回答
0
投票

没有什么区别。

const void *ptr
void const *ptr
定义具有
ptr
类型的对象
pointer to const void

如果将 const 移到

*
之外,它将改变定义的制定。

void * const ptr;

ptr
定义为
const pointer to void

© www.soinside.com 2019 - 2024. All rights reserved.