[英]Typecasting from pointers to uint32
Iam going through a linker descriptor file and found following lines of code and I am unable to understand the typecasting concept used here. 我正在浏览链接描述文件,发现以下代码行,我无法理解此处使用的类型转换概念。
extern std::uintptr_t __sROData_LMA[]; /* start of LOAD region for DATA */
uint32_t * p_src, * p_dest;
#ifdef XMC_BOOT
// Copy the rodata segment initializers from ROM to RAM.
// Note that all data segments are aligned by 4.
p_src = static_cast<uint32_t *>(static_cast<void*>(__sROData_LMA));
p_dest = static_cast<uint32_t *>(static_cast<void*>(__sROData));
while (p_dest < static_cast<uint32_t*>(static_cast<void*>(__eROData)))
{
*p_dest++ = *p_src++;
}
#endif
What does the line p_src = static_cast<uint32_t *>(static_cast<void*>(__sROData_LMA));
行
p_src = static_cast<uint32_t *>(static_cast<void*>(__sROData_LMA));
meant in the program? 在程序中意味着什么? How is typecasting being done here?
在这里如何进行类型转换? Thanks in advance.
提前致谢。
The thing is, that you cannot dereference a void pointer, but a uint32_t pointer. 事实是,您不能取消引用空指针,而只能取消引用uint32_t指针。 The code itself is used for
Copy the rodata segment initializers from ROM to RAM.
该代码本身用于
Copy the rodata segment initializers from ROM to RAM.
, which is afaik required for ELF binaries. ,这是ELF二进制文件所需的afaik。 In fact, this is a
mempcy
. 实际上,这是一种
mempcy
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.