头文件自定义了bool类型,4个字节:
#ifndef bool
#define bool int
#define true 1
#define false 0
#endif
typedef struct {
bool automaticActivation;
bool testCall;
bool positionCanBeTrusted;
msd_VehicleType_t vehType;
} msd_Control_t;
typedef struct {
uint8_t messageIdentifier;
msd_Control_t control;
char vehIdentificationNumber[18];
msd_VehiclePropulsionStorageType_t vehPropulsionStorageType;
} msd_Structure_t;
而另一个文件因为包含了标准头文件,bool对应的一个字节:
#include <stdbool.h>
int main()
{
msd_t msd = {0};
uint8_t builtMsd[QL_ECALL_MSD_MAX_LEN];
g_debug("VIN: %17s",(char*)msd.msdMsg.msdStruct.vehIdentificationNumber0;
encodeMsdMessage(&msd, builtMsd);
}
main()中打印的VIN:ECALLEXAMPLE02013
encodeMsdMessage()中打印的VIN:MPLE02013, 少了8个字符.
原因就是main()编译使用的一个字节的bool,encodeMsdMessage()编译用的是自定义的4字节bool.