2024-01-04 05:35 AM
Hello, I want to write data to a SD card. When I want to include fatfs, in header files i get errors.
ff_gen_drv.h line 57 (typedef struct { uint8_t is_initialized[_VOLUMES];:( '_VOLUMES' undeclared here (not in a function)
sd_diskio.h line 35 (extern const Diskio_drvTypeDef SD_Driver;:( unknown type name 'Diskio_drvTypeDef'
sd_diskio.c line 70 (const Diskio_drvTypeDef SD_Driver =:( conflicting types for 'SD_Driver'; have 'Diskio_drvTypeDef'
fatfs.h line 36 (extern FATFS SDFatFS;:( unknown type name 'FATFS'
fatfs.h line 37 (extern FIL SDFile;:( unknown type name 'FIL'
I enabled SDIO and FatFS and generated the code.
In the code I deleted #include "fatfs.h" line in main.c. After that, I created 2 new files called "sd.c" and "sd.h" in /Core/User folder which i've created.
SD.H file:
#ifndef USER_SD_H_
#define USER_SD_H_
#include "fatfs.h"
#endif /* USER_SD_H_ */
SD.C file:
#include "sd.h"
main.h file:
/* USER CODE BEGIN Includes */
#include "sd.h"
/* USER CODE END Includes */
I want to be able to include "fatfs.h" file in other files. Right now i am only able to include it in the .c files. When i want to include it in .h files, i get errors. How can i fix this?
2024-01-05 12:52 AM
Hello @ÇSerp.1 ,
The problem here seems to be related to the configuration of your project.
Look at the Include Paths settings and make sure that your project has the right include paths and the compiler knows the path to fatfs.h.
2024-01-07 11:38 PM
Hello @Imen.D
I don't see any problems with the include paths. Here are my include paths and files:
Include paths:
Files:
SD.h
SD.c
main.h
Errors:
../Middlewares/Third_Party/FatFs/src/ff_gen_drv.h:57:42: error: '_VOLUMES' undeclared here (not in a function)
../FATFS/App/fatfs.h:36:8: error: unknown type name 'FATFS'
../FATFS/App/fatfs.h:37:8: error: unknown type name 'FIL'
../FATFS/Target/sd_diskio.h:35:14: error: unknown type name 'Diskio_drvTypeDef'
2024-01-07 11:48 PM - edited 2024-01-07 11:48 PM
I also get errors if i move #include "fatfs.h" from main.c to main.h. Normally, when i created the project, "fatfs.h" is already included in main.c. If I don't include "sd.h" file to "main.h" and just move the inclusion of "fatfs.h" from main.c to main.h, i get the same errors.
2024-06-12 07:32 PM
我也遇到了此问题,可以试着将#include “ff_gen_drv.h”移动到sd_diskio.h,目前我这的报错已经消失且编译通过,这一操作对你来说也许可以解决问题