main.c:
int32_t main(void)
{
ObjDetection_Perframe* rawcloudpoints;
rawcloudpoints = (ObjDetection_Perframe*)malloc(sizeof(ObjDetection_Perframe));
printf(" %x\n %x\n %x\n %x\n %x\n %x\n %d\n %d\n %d\n %d\n %d\n", rawcloudpoints, &(rawcloudpoints->detList), &(rawcloudpoints->frameNum), &(rawcloudpoints->vel), &(rawcloudpoints->yaw), &(rawcloudpoints->num), sizeof(ObjDetection_Perframe), sizeof(float), sizeof(double), sizeof(rawcloudpoints->detList), sizeof(rawcloudpoints));
return 0;
}
main.h:
typedef struct Cloud_Points_Perframe_t
{
float range; //表示该detection的距离
float doppler; //表示该detection的doppler速度
float vel; //表示该detection的解模糊后的径向速度
float aziAngle; //表示该detection的方位角
float eleAngle; //表示该detection的俯仰角
float sn; //表示该detection的信噪比
float x; //表示该detection的横向距离
float y; //表示该detection的纵向距离
float z; //表示该detection的高度
}Cloud_Points_Perframe;
typedef struct ObjDetection_Perframe_t
{
Cloud_Points_Perframe* detList; //表示该帧点云信息,是个数组,每个元素代表一个detection的信息
uint32_t frameNum; //表示该帧的帧号
float vel; //表示该帧的自车速度
float yaw; //表示该帧的偏航角
uint32_t num; //表示该帧点云数量
}ObjDetection_Perframe;
输出:
总结:
数据类型:
其他:
1.指针可以理解为一串含义为地址的二进制数(相较于变量的二进制表示变量值而言),指针取地址,表示存放该地址的指针在内存中的索引(地址);
2.结构体指针默认分配为float(不同编译器所占字节不同,x86为4字节,x64为8字节),其值为所对应的结构体内存的首地址(也就是该内嵌结构体的第一个成员的首地址),可用->直接访问得到该地址,若对其取地址,可得到该指针所存放的地址(也就是当前结构体存放该内嵌结构体指针的索引,即该指针的地址);
3.注意结构体字节对齐。