有人能说说这段代码是什么意思吗?
void (* const rvt[])(void) = {
(void (*) (void))((unsigned long)&__STACK_END), // The initial stack pointer
xkg_som, // The reset handler
xnt_ISR, // The NMI handler
FaultISR, // The hard fault handler
IntDefaultHandler, // The MPU fault handler
bgs_stm, // The bus fault handler
IntDefaultHandler, // The usage fault handler
0, // Reserved
0, // Reserved
IntDefaultHandler, // The MPU fault handler
};
其实我没看懂
最佳答案
void (* const rvt[])(void)
手段(由 cdecl.org 提供):
declare rvt as array of const pointer to function (void) returning void
T foo = {
value1,
value2,
value3 // ...
};
这是 aggregate initialization [1] 的数组。此外,这意味着 rvt
的声明是一个定义。
&__STACK_END
addresof 运算符获取变量的内存地址。
(unsigned long)&__STACK_END)
地址被转换为unsigned long
类型。
(void (*) (void))((unsigned long)&__STACK_END)
转换后的值再次转换为指向返回 void 的函数 (void) 的指针,这是存储在数组中的函数指针的类型。
数组的其余初始化值可以是函数名、函数指针或可以隐式转换为函数指针的东西,例如 lambda。
关于c++ - 这部分代码是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40607287/