Bonjour, je cherche à utiliser les directives de compilation sur un ESP32 pour charger et utiliser des bibliothèques selon une valeur.
Voici le code :
#include "FS.h"
#define FileSystem FFat
#if defined FileSystem && FileSystem == SPIFFS
#include <SPIFFS.h>
#elif defined FileSystem && FileSystem == FFat
#include <FFat.h>
#elif defined FileSystem && FileSystem == LittleFS
#include <LittleFS.h>
#endif
void setup() {
Serial.begin(115200);
delay(1000);
// Initialize the file system
if (!FileSystem.begin()) {
Serial.println("Initialization failed!");
return;
}
Serial.print("File system used: ");
Serial.print(FileSystem.usedBytes());
Serial.println(" bytes");
Serial.print("Total space: ");
Serial.print(FileSystem.totalBytes());
Serial.println(" bytes");
#if FileSystem == FFat
Serial.print("Free space: ");
Serial.print(FileSystem.freeBytes());
Serial.println(" bytes");
#endif
}
void loop() {
// Do Nothing Here
}
Mais j'obtiens une erreur de compilation :
C:\Users\fa125436\AppData\Local\Temp\.arduinoIDE-unsaved2024728-29468-2g4cxh.vxsyb\sketch_aug28a\sketch_aug28a.ino: In function 'void setup()':
C:\Users\fa125436\AppData\Local\Temp\.arduinoIDE-unsaved2024728-29468-2g4cxh.vxsyb\sketch_aug28a\sketch_aug28a.ino:2:20: error: 'FFat' was not declared in this scope
2 | #define FileSystem FFat
| ^~~~
C:\Users\fa125436\AppData\Local\Temp\.arduinoIDE-unsaved2024728-29468-2g4cxh.vxsyb\sketch_aug28a\sketch_aug28a.ino:16:8: note: in expansion of macro 'FileSystem'
16 | if (!FileSystem.begin()) {
| ^~~~~~~~~~
C:\Users\fa125436\AppData\Local\Temp\.arduinoIDE-unsaved2024728-29468-2g4cxh.vxsyb\sketch_aug28a\sketch_aug28a.ino:2:20: error: 'FFat' was not declared in this scope
2 | #define FileSystem FFat
| ^~~~
C:\Users\fa125436\AppData\Local\Temp\.arduinoIDE-unsaved2024728-29468-2g4cxh.vxsyb\sketch_aug28a\sketch_aug28a.ino:22:16: note: in expansion of macro 'FileSystem'
22 | Serial.print(FileSystem.usedBytes());
| ^~~~~~~~~~
exit status 1
Compilation error: 'FFat' was not declared in this scope
C'est le #define
qui ne fonctionne pas comme prévu. Où est le problème ?
Merci