Linux caddr_t 的意义是什么,什么时候使用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6381526/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the significance of caddr_t and when is it used?
提问by kingsmasher1
Can somebody please tell me:
有人可以告诉我:
- What is
caddr_t
? - When is it used ?
- How it is different from
void*
? - When to use
void*
and when to usecaddr_t
?
- 什么是
caddr_t
? - 什么时候使用?
- 它与
void*
?有什么不同? - 何时使用
void*
,何时使用caddr_t
?
Thanks in advance.
提前致谢。
采纳答案by R.. GitHub STOP HELPING ICE
caddr_t
is a legacy BSD type associated with some low level calls like mmap
, and it should never be used in modern code. It was rejected by the POSIX standard. The standardized mmap
uses void *
.
caddr_t
是与一些低级调用相关的遗留 BSD 类型,如mmap
,它永远不应该在现代代码中使用。它被 POSIX 标准拒绝。标准化mmap
使用void *
。
回答by Keith Smith
caddr_t
was used as a pointer to a core address. I used it in SVR4 when I needed to access kernel structures from user space (having used mmap to access /dev/kmem
). Even when "/proc
" existed, the ps command still used mmap of the kernel to start walking the process table. As everybody states it was superseded by void *.
caddr_t
被用作指向核心地址的指针。当我需要从用户空间访问内核结构时(使用 mmap 访问/dev/kmem
),我在 SVR4 中使用了它。即使/proc
存在“ ”,ps 命令仍然使用内核的 mmap 开始遍历进程表。正如每个人所说,它已被 void * 取代。