【发布时间】:2018-05-09 01:10:19
【问题描述】:
这是我所拥有的,但仍然存在问题 - 编译器无法识别“my_reg”结构类型。
../Source/functions.c:609:16: error: 'my_reg' undeclared (首先在这个函数中使用) ModBusIDReg = (my_reg)const_ModBusIDReg;
// define structure in flash with constants
struct
{
const unsigned char Reg00[32];
const unsigned char Reg01[32];
const unsigned char Reg02[32];
const unsigned short Reg03;
const unsigned short Reg04;
} const_ModBusIDReg =
{
"My String 1" ,
"My String 2" ,
"My String 3" ,
0 ,
0
};
// define structure in RAM, tag name "my_reg"
struct my_reg
{
unsigned char Reg00[32];
unsigned char Reg01[32];
unsigned char Reg02[32];
unsigned short Reg03;
unsigned short Reg04;
} ModBusIDReg;
// This statement is located in InitSys function.
// Both of the files where the structures were
// defined are included at the top of the file
// where InitSys function resides.
// Make a copy of const_ModBusIDReg from
// flash into ModBusIDReg in RAM.
ModBusIDReg = (my_reg)const_ModBusIDReg;
关于如何进行直接分配的任何想法?
【问题讨论】:
-
memcpy()是执行此操作的适当且有效的方法。