我需要转换此结构
dt[, age := decimal_date(disease.date) - decimal_date(dob)]
到 typedef struct zidrecord2 {
char version;
char flags;
char filler1;
char filler2;
unsigned char identifier[IDENTIFIER_LEN];
unsigned char rs1Interval[TIME_LENGTH];
unsigned char rs1Data[RS_LENGTH];
unsigned char rs2Interval[TIME_LENGTH];
unsigned char rs2Data[RS_LENGTH];
unsigned char mitmKey[RS_LENGTH];
}
或另一个允许再次回滚到该对象的对象
我试试这个:
char *
但是我收到以下错误:
zidrecord2_t* amostra = zidRecord->getRecordData();
const char *recordData = reinterpret_cast<const char*>(zidRecord->getRecordData());
__android_log_print(ANDROID_LOG_INFO, "MyTag", "The value is %s",recordData);
amostra = reinterpret_cast<zidrecord2_t*>(recordData);
__android_log_print(ANDROID_LOG_INFO, "MyTag", "The value is %s",recordData);
我怎样才能传递这个问题?或以另一种方式实施?
答案 0 :(得分:2)
amostra = reinterpret_cast<const zidrecord2_t*>(recordData);
从const
投射到const
。
如果你想展开const
,请从头开始使用非const
指针。
答案 1 :(得分:0)
您可以添加用户定义的转换运算符:
因此,您的代码可能如下所示:
typedef struct zidrecord2 {
char version;
char flags;
char filler1;
char filler2;
unsigned char identifier[IDENTIFIER_LEN];
unsigned char rs1Interval[TIME_LENGTH];
unsigned char rs1Data[RS_LENGTH];
unsigned char rs2Interval[TIME_LENGTH];
unsigned char rs2Data[RS_LENGTH];
unsigned char mitmKey[RS_LENGTH];
operator char*() const { return ConvertToCharPointerHere();
}