[英]Confused about macros using pointers in C
I want to understand this bit of code 我想了解这段代码
#define GET(p) (*(unsigned int*) (p))
I learned about pointers but I can't figure out what the statement above means. 我了解了指针,但是我无法弄清楚上面的语句意味着什么。 When I use GET(ptr), am I getting the value at the address ptr points to or the address that ptr contains? 当我使用GET(ptr)时,我是在指向ptr的地址还是指向ptr包含的地址处获取值?
It means the following. 这意味着以下内容。
p
to the type unsigned int*
. 将指针p
强制转换为unsigned int*
类型。 Another way of putting it is that the macro gets the value of the unsigned int
at the address specified by p
. 另一种放置方法是,宏在p
指定的地址处获取unsigned int
的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.