C の型キャストに関連するエラーに遭遇しました。unioffs と呼ばれる float 値を保持する構造体があり、その float 値をバッファに取り込む必要があります。そのために memcopy 関数を使用しています。以下は私が実装したものです。
typedef struct __attribute__ ((aligned (1), packed))
{
/*01 Bytes*/ uint8_t flags;
/*01 Bytes*/ uint8_t store;
/*04 Bytes*/ float unioffs; /* detector offset in univalues default=0 */
/*04 Bytes*/ float scale; /* detector scale - default =1 */
/*04 Bytes*/ float valalrm; /* value alarm level - in univalue*/
/*04 Bytes*/ float dosalrm; /* dose alarm level - in unidose*/
/*04 Bytes*/ float samperc; /* percentage of the output sampled */
/*04 Bytes*/ float dcstime; /* time of the exposure in seconds */
/*03 Bytes*/ int8_t fillup[3]; /* !!!! allways fill up to 29 bytes */
} DET_STUP;
int main()
{
DET_STUP det_stup[DET_NROFCHAN]; //NROFCHAN is #defined is 10
uint8_t response_to_LV[42];
memset(response_to_LV,0,42);
memset(guc_sensor_config_data,0,40);
//guc_sensor_config_data is a global buffer of 40 bytes
memcpy(guc_sensor_config_data+1*14,(float*)det_stup.unioffs,4);
//Further implementaions to send the buffer through UART
}
私がここで得ているエラーは次のとおりです: error#171: 無効な型変換
私は何を間違っていますか?