错误:当我试图实现嵌套结构时,不允许使用不完整的类型
error: incomplete type is not allowed with when i tried to implement nested structure
我试图创建一个结构,就像下面一样,它将更像嵌套结构,我已经创建了,但它抛出了一个错误,如不完整的类型是不允许的,而从结构SGebObjLst
调用结构SGenObjData
struct SGenObjLst
{
unsigned short objectIdx[OBJ_MAX_ID + 1][SRC_LIST_NMBR]; /* #RTAS: input */
struct SGenObjData objects[OBJ_MAX_NMBR]; /* #RTAS: input */
unsigned short objNmbr; /* #RTAS: input */
unsigned char modifiedFlag; /* #RTAS: input */
unsigned char validFlag; /* #RTAS: input */
};
struct SGenObjData
{
enum TObjType recogType; /* #RTAS: input */ /* Object type (vehicle, pedestrian, ...) */
enum TObjType commuType; /* #RTAS: input */ /* Object type (vehicle, pedestrian, ...) */
enum TSource source; /* #RTAS: input */ /* id offset e.g. 0 for "GenericEnvObjectList" = "GEOL" */
unsigned short id; /* #RTAS: input */ /* object id */
unsigned char reliability; /* #RTAS: input */ /* 0: undefined 1: very low 2: low 3: medium 4: high 5: very high */
unsigned char vulnerability; /* #RTAS: input */ /* 0: not vulnerable (e.g. parked car), ... 5: very vulnerable (e.g. child) */
unsigned char dangerousness; /* #RTAS: input */ /* 0: not dangerous for ego vehicle (e.g. a small bush), ... 5: very dangerous (e.g. wall) */
TTime timestamp; /* #RTAS: input, unit: us */ /* timestamp [us] */
TTime measTimestamp; /* #RTAS: input, unit: us */ /* original measured timestamp (w/o correction due to delay time compensation) */
float x; /* #RTAS: input, unit: m */ /* x position (ego vehicle front is zero)[m] */
float err_x; /* #RTAS: input, unit: m */ /* x position error [m] */
float y; /* #RTAS: input, unit: m */ /* y position (ego vehicle middle axle is zero) [m] */
float err_y; /* #RTAS: input, unit: m */ /* y position error [m] */
float vx_rel; /* #RTAS: input, unit: m/s */ /* relative velocity x [m/s] */
float vy_rel; /* #RTAS: input, unit: m/s */ /* relative velocity y [m/s] */
float ax_rel; /* #RTAS: input, unit: m/s**2 */ /* relative acceleration x [m/s2] */
float vx_abs; /* #RTAS: input, unit: m/s */ /* absolute velocity x [m/s] */
float vy_abs; /* #RTAS: input, unit: m/s */ /* absolute velocity y [m/s] */
float ax_abs; /* #RTAS: input, unit: m/s**2 */ /* absolute acceleration x [m/s2] */
float width; /* #RTAS: input, unit: m */ /* width of object */
float err_width; /* #RTAS: input, unit: m */ /* width error of object */
float length; /* #RTAS: input, unit: m */ /* length of object */
float err_length; /* #RTAS: input, unit: m */ /* length error of object */
float height; /* #RTAS: input, unit: m */ /* height of object */
float err_height; /* #RTAS: input, unit: m */ /* height error of object */
float maxVel; /* #RTAS: input, unit: m/s */ /* maximal speed observed during tracking */
unsigned char vldty_width; /* #RTAS: input */
unsigned char vldty_err_width; /* #RTAS: input */
unsigned char vldty_length; /* #RTAS: input */
unsigned char vldty_err_length; /* #RTAS: input */
unsigned char vldty_height; /* #RTAS: input */
unsigned char vldty_err_height; /* #RTAS: input */
unsigned char vldty_x; /* #RTAS: input */
unsigned char vldty_err_x; /* #RTAS: input */
unsigned char vldty_y; /* #RTAS: input */
unsigned char vldty_err_y; /* #RTAS: input */
unsigned char vldty_vx_rel; /* #RTAS: input */
unsigned char vldty_vy_rel; /* #RTAS: input */
unsigned char vldty_ax_rel; /* #RTAS: input */
unsigned char vldty_vx_abs; /* #RTAS: input */
unsigned char vldty_vy_abs; /* #RTAS: input */
unsigned char vldty_ax_abs; /* #RTAS: input */
unsigned char vldty_maxVel; /* #RTAS: input */
};
// CREATE STRUCT
struct SGenObjLst objectList;
struct SGenObjData objectData;
struct SGenDataLst //sundar
{
struct SGenObjLst objectList;
struct SGenObjData objectData;
};
struct SGenDataLst SGenDataLst;
您使用与类型相同的名称调用对象。您不能这样做,因为这样编译器会将类型解释为另一个声明,例如:
struct SGenDataLst SGenDataLst; // is the equivallent of:
int int;
不起作用-编译器将看到两个int
并尝试声明第一个int,它将是空的-因为两个int之间没有名称,然后是另一个新的。因此,您可能会得到许多不同的错误,而唯一的问题是重复的名称。
试试这个:
struct SGenDataLst myDataList; // or any other name.
编辑:
从注释中我注意到你还以错误的顺序声明了你的结构。这也会引发与您得到的错误类似的错误,因为大多数C编译器都是反向读取的。按照amartel的建议,更改顺序,您的程序应该可以正常工作。
相关文章:
- C++从外部类继承的嵌套类;不允许使用不完整的类型
- 数组错误(不允许类型不完整)
- 类中不允许使用不完整的类型,但在类模板中允许使用不完整的类型
- AActor *UactorComponent::GetOwner const - 不允许指向不完整类类型的指针
- 不允许使用不完整的类型
- C++ - 声明结构和类时不允许使用不完整的类型
- 虚幻引擎 4.18.0,VS2017,不允许指向不完整类类型的错误指针
- 分部模板类中不允许指向不完整类类型的指针
- PCL :: PointXyz不允许使用不完整的类型
- 我的库中有多个类:不允许使用不完整的类型
- 错误:不允许指向不完整类类型的指针.我该怎么做
- 不允许指向不完整类类型的指针
- 错误:不允许指向不完整类类型的指针
- 不允许指向不完整类类型的指针.(与相互引用的类相结合.)
- 不允许使用不完整类型的推力copy_if
- 使用类类型的向量进行前向声明——不允许指向不完整类类型的指针
- 在尝试创建指针数组时,不允许使用不完整类型
- 不允许指向不完整类类型的c++指针
- 错误,不允许类型不完整
- 类构造函数:不允许类型不完整(在成员列表中)-VS C++w/QT