【发布时间】:2021-12-31 19:47:42
【问题描述】:
我正在开发 C 程序来读取门禁状态。我创建了一个结构,其中声明了两个数组。我想在定义该结构时初始化数组。 例如,
.h 文件中的结构声明:
typedef volatile struct
{
uint8_t __near const * const people_in_input_ports[8];
uint8_t __near const * const people_out_input_ports[8];
}GATE_ACCESS_CTRL_BLOCK;
.c 文件中的结构体定义:
GATE_ACCESS_CTRL_BLOCK g_gate_acc_parameters = {
.people_in_input_ports = {&P12, &P4, &P4, &P4, &P6, &P6, &P6, &P6},
.people_out_input_ports = {&P14, &P14, &P2, &P14, &P14, &P5, &P5, &P1}
};
这里P12、P4、P6、P5、P2和P14是对应端口的sfr地址。
我收到以下错误。
E0520029:Expected an expression
E0520029:Expected an expression
如何使用数组名来初始化结构内声明的数组?
【问题讨论】:
标签: arrays c struct initialization embedded