我正在使用该功能
int max30205_write_trip_low_thyst(float temperature)//, I2C &i2c_bus)
{
max30205_raw_data raw;
temperature /= MAX30205_CF_LSB;
raw.swrd = int16_t(temperature); // here -> expected expression before 'int16_t'
return max30205_write_reg16(raw.swrd, MAX30205_REG_THYST_LOW_TRIP);//, i2c_bus);
}
,当我尝试编译时,出现以下错误
expected expression before 'int16_t'
这是为什么?
查看头文件,我看到了
#define MAX30205_CF_LSB (0.00390625F)
typedef union max30205_raw_data {
struct {
uint8_t lsb;
uint8_t msb;
};
struct {
uint16_t magnitude_bits:15;
uint16_t sign_bit:1;
};
uint16_t uwrd;
int16_t swrd;
} max30205_raw_data;
答案 0 :(得分:4)
因为int16_t(temperature);
是无效的C语法。您需要执行(int16_t)temperature
。