-2
我在文件platform.h
的結構定義:typedef結構指針
typedef struct {
VL53L0X_DevData_t Data;
uint8_t I2cDevAddr;
uint8_t comms_type;
uint16_t comms_speed_khz;
uint16_t devID;
I2C_HandleTypeDef * i2c_handle;
} VL53L0X_Dev_t;
而且在同一個文件的類型定義的指針這樣的:
typedef VL53L0X_Dev_t* VL53L0X_DEV;
在另一個文件中,參考到VL53L0X_DEV
失敗error: unknown type name 'VL53L0X_DEV'
我在其他文件中包含platform.h
。這有什麼問題?
EDIT
我卡使用由供應商提供的,因此沒有多大範圍是否與指針的typedef廢除或用於提供MCVE示例這個代碼(它的很多) 。這是相關的構建日誌。它似乎包括vl53l0x_platform.h
文件好吧。謝謝你的幫助!
1> >>Building build/vl53l0x_platform.o
1> arm-none-eabi-gcc -ffreestanding -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-move-loop-invariants -g3 -nostartfiles -I"conf" -I"inc" -IC:/Users/sohail/Documents/Cloud/STM32Cube_FW_F4_V1.7.0/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/Users/sohail/Documents/Cloud/STM32Cube_FW_F4_V1.7.0/Drivers/CMSIS/Include -I"C:\Users\sohail\Documents\gcc-arm_launchpad_binaries\lib\gcc\arm-none-eabi\4.9.3\include" -I"C:\Users\sohail\Documents\gcc-arm_launchpad_binaries\arm-none-eabi\include\sys" -I"C:\Users\sohail\Documents\gcc-arm_launchpad_binaries\arm-none-eabi\include" -std=gnu11 -c -o build/vl53l0x_platform.o src/vl53l0x_platform.c
1> In file included from inc/vl53l0x_api.h:33:0,
1> from inc/main.h:44,
1> from inc/vl53l0x_platform.h:34,
1> from src/vl53l0x_platform.c:37:
1> inc/vl53l0x_api_strings.h:39:39: error: unknown type name 'VL53L0X_DEV'
1> VL53L0X_Error VL53L0X_get_device_info(VL53L0X_DEV Dev, VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo);
1> ^
檢查預處理的代碼。 –
您應該發佈[MCVE](http://stackoverflow.com/help/mcve) – LPs
完全猜測:「paltform.h」之前包含的某些include需要「VL53L0X_DEV」類型?如果是'platform.h'必須位於其他頭文件的頂部。 – LPs