Skip to content

SD and FS (SPIFFS) library naming collision #3819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pfabri opened this issue Nov 11, 2017 · 4 comments
Closed

SD and FS (SPIFFS) library naming collision #3819

pfabri opened this issue Nov 11, 2017 · 4 comments

Comments

@pfabri
Copy link

pfabri commented Nov 11, 2017

Description

<FS.h> and <SD.h> can't both be used in a sketch because of a naming collision. The File type, for example, is declared by both libraries. Attempting to build the code below will throw an error:

Sketch

#include <Arduino.h>
#include <SD.h>
#include <FS.h>

void setup() {

}

void loop() {

}

Debug Messages

Compiling .pioenvs/d1_mini/src/main.o
In file included from src/main.cpp:8:0:

/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/FS.h:133:11: error: 'File' is already declared in this scope
using fs::File;
^
*** [.pioenvs/d1_mini/src/main.o] Error 1
@luc-github
Copy link
Contributor

Use #define FS_NO_GLOBALS before include FS
so you can use fs::File for SPIFFS and File for SD

@pfabri
Copy link
Author

pfabri commented Nov 11, 2017

@luc-github Marvellous, it works, thank you!
For those interested in digging deeper: #issue112 - ESPAsyncWebServer

@pfabri pfabri closed this as completed Nov 11, 2017
@Misiu
Copy link

Misiu commented Apr 27, 2018

@luc-github I was searching for solution to use ESPAsyncWebServer and SD card. Your solution works, thank Yo. However I think it is only temporary.
can both SPIFFS and SD have namespaces? fs:: for SPIFFS and sd:: for SD?
Also I found interesting thread: #4201
Would it solve problem with namespaces? If it would be same base File class then conflict should disappear.
Please correct me if I'm wrong.

@luc-github
Copy link
Contributor

temporary solutions can exist for a long time ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants