我读了这段宏(C 代码),并在解码它以了解它定义的内容时感到困惑。它定义了什么?
#define sram (*((unsigned char (*)[1]) 0))
-广告
最佳答案
我认为 sram
的意思是“RAM 的开始”。
unsigned char[1]
大小为 1 的无符号字符数组。
unsigned char(*)[1]
A pointer to an array大小为 1 的无符号字符。
(unsigned char (*)[1]) 0
将 0 转换为指向大小为 1 的无符号字符数组的指针。
*((unsigned char (*)[1]) 0)
读取位置 0 的一些内存,并将结果解释为大小为 1 的无符号字符数组。
(*((unsigned char (*)[1]) 0))
#define sram (*((unsigned char (*)[1]) 0))
将变量 sram
定义为从位置 0 开始的内存,并将结果解释为大小为 1 的无符号字符数组。
关于c - 这个宏定义了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2320527/