【发布时间】:2021-06-25 15:25:40
【问题描述】:
我正在尝试用 C++ 初始化一个结构数组。
这是我的结构:
typedef ap_fixed<16,1> ap_fixed_data_type;
typedef struct {
ap_fixed_data_type real_part;
ap_fixed_data_type imaginary_part;
} my_data_struct;
这是我的结构数组:
static my_data_struct IFFT_output[1024];
我想使用(如果可能的话)标准数组的相同“语法”来初始化我的结构数组,例如:
int my_array[1024] = {0};
这会将我的数组初始化为全 0。
我想要达到的目标是:
static my_data_struct IFFT_output[1024]={{0,0}};
此代码应将每个结构中的每个字段(real_part 和 imaginary_part)初始化为 0。
使用上面的代码我得到这个错误:
在抛出一个实例后调用终止 '__gnu_cxx::recursive_init_error'
这似乎是由错误的初始化静态变量(如here)引起的。
我知道我可以使用简单的for 循环来初始化我的数据,但我想做一些更“紧凑”的事情。
有没有办法用上面显示的“语法”初始化我的结构数组?
【问题讨论】:
-
我的错,错字。固定
标签: c++ arrays struct initialization vivado