我想了解一個輪胎壓力監測系統的軟件,但我對C語言知之甚少。 在頭文件中的一個有這幾樣定義:將函數強制轉換爲c程序中的函數指針
#define TPMS_RESET gu16AddressToFn = u16fnDALLinkFmw(gu8Derivative, FN_RESET);\
((void(*)(void))(gu16AddressToFn))
/* UINT8 TPMS_READ_VOLTAGE(UINT16 *u16UUMA) */
#define TPMS_READ_VOLTAGE ((UINT8(*)(UINT16*))(u16fnDALLinkFmw(gu8Derivative, FN_READ_VOLT)))
/* UINT8 TPMS_COMP_VOLTAGE(UINT8 *u8CompVoltage, *UINT16 u16UUMA) */
#define TPMS_COMP_VOLTAGE ((UINT8(*)(UINT8*, UINT16*))(u16fnDALLinkFmw(gu8Derivative, FN_COMP_V)))
/* UINT8 TPMS_READ_TEMPERATURE(UINT16 *u16UUMA) */
#define TPMS_READ_TEMPERATURE ((UINT8(*)(UINT16*))(u16fnDALLinkFmw(gu8Derivative, FN_READ_T)))
/* UINT8 TPMS_COMP_TEMPERATURE(UINT8 *u8Temp, UINT16 *u16UUMA) */
#define TPMS_COMP_TEMPERATURE ((UINT8(*)(UINT8*, UINT16*))(u16fnDALLinkFmw(gu8Derivative, FN_COMP_T)))
/* UINT8 TPMS_READ_PRESSURE(UINT16 *u16UUMA, UINT8 u8Avg) */
#define TPMS_READ_PRESSURE ((UINT8(*)(UINT16*, UINT8))(u16fnDALLinkFmw(gu8Derivative, FN_READ_P)))
/* UINT8 TPMS_COMP_PRESSURE(UINT16 *u16CompPressure, UINT16 *u16UUMA) */
#define TPMS_COMP_PRESSURE ((UINT8(*)(UINT16*, UINT16*))(u16fnDALLinkFmw(gu8Derivative, FN_COMP_P)))
/* UINT8 TPMS_READ_ACCEL_X(UINT16 *u16UUMA, UINT8 u8Avg, UINT8 u8FiltSelect, UINT8 u8DynamicOffset) */
#define TPMS_READ_ACCEL_X ((UINT8(*)(UINT16*, UINT8, UINT8, UINT8))(u16fnDALLinkFmw(gu8Derivative, FN_READ_X)))
/* UINT8 TPMS_READ_ACCEL_Z(UINT16 *u16UUMA, UINT8 u8Avg, UINT8 u8FiltSelect, UINT8 u8DynamicOffset) */
#define TPMS_READ_ACCEL_Z ((UINT8(*)(UINT16*, UINT8, UINT8, UINT8))(u16fnDALLinkFmw(gu8Derivative, FN_READ_Z)))
我不真正瞭解鑄造成其他功能的這一招。你有什麼想法嗎?
什麼是'u16fnDALLinkFmw'?什麼是'gu8Derivative'? –
這是一個很好的例子,使用'typedef'會導致更多可理解的代碼。 –