Skip to main content
AndreasPA
Associate III
Jun 11, 2021 3:45 AM UTC
Solved

Including Fatfs.h into main.h causes a metric ton of issues

Hello,

Doing some work using sd cards, and noticed that if i were to use the main.h file and have all my fatfs.h declared all the structs like FATFS / FIL / FRESULT spit out errors that theyre undefiend when cntrl clicking takes me to the file.

unknown type name 'FATFS' (same with the remainder structs)

if i instead make my own file in src called x.h and copy the same code over i get no issues.

Any ideas ?

Latest version of cubemx

a quick snippit of the setup code is

#include "stdint.h"

#include "fatfs.h"

 FATFS FS;

 FIL fil;

 FRESULT fres;

int MountReadSDCard(){

 //Mount SSD and copy over the files

 if ((fres = f_mount(&FS, "", 1)) == FR_OK) {

   /* Try to open file */

 HAL_Delay(50);

   if ((fres = f_open(&fil, "out.bin", FA_READ)) == FR_OK) {

}

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
Jun 11, 2021 5:59 AM UTC

Make sure the compiler knows the path to fatfs.h. Details depends on your particular toolchan, read the toolchain's manual.

JW

2 replies

waclawek.jan
waclawek.janBest answer
Super User
Jun 11, 2021 5:59 AM UTC

Make sure the compiler knows the path to fatfs.h. Details depends on your particular toolchan, read the toolchain's manual.

JW

AndreasPA
AndreasPAAuthor
Associate III
Jun 15, 2021 6:18 AM UTC

Thanks, completely forgot about the PATH, honestly assumed that it would of already been in there