使用 memcpy(...) 读取物理地址处的值
Using memcpy(...) to read Value(s) at a Physical Address
我需要读取地址为0x2428(MCU的闪存)的值。如何使用memcpy读取值?
uint8_t *newData ,x;
memcpy( newData, 0x2428, sizeof x);
但是,我明白了
Error[Pe167]: argument of type "int" is incompatible with parameter of
type "void const *
我该如何修正错误?
您试图将内存地址 (0x2428) 作为 memcpy 操作的目标地址传递,但编译器在期望 const void * 时只是将其视为 const int 值(整数文字)。您至少必须将其转换为 (const void *) 0x2428 的数据类型才能使此语法起作用。
我需要读取地址为0x2428(MCU的闪存)的值。如何使用memcpy读取值?
uint8_t *newData ,x;
memcpy( newData, 0x2428, sizeof x);
但是,我明白了
Error[Pe167]: argument of type "int" is incompatible with parameter of type "void const *
我该如何修正错误?
您试图将内存地址 (0x2428) 作为 memcpy 操作的目标地址传递,但编译器在期望 const void * 时只是将其视为 const int 值(整数文字)。您至少必须将其转换为 (const void *) 0x2428 的数据类型才能使此语法起作用。