FILE_APPEND was not declared in this scope

Hello guys!

I'm using the following code with Arduino IDE 2.0.0-beta.5 to generate code for an ESP8266 (added with this JSON):

File sdFile =, FILE_APPEND);

and I got this error message:

c:\Users\myUser\Documents\Arduino\libraries\dogBoxLib\utility\helper.cpp:68:37: error: 'FILE_APPEND' was not declared in this scope File sdFile =, FILE_APPEND);

The console also says this (I deleted all other Arduino IDE installations):

Using library SD at version 2.0.0 in folder: C:\Users\myUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\SD

The mentioned SD library has the following code in its SD.h file:

#undef FILE_READ
#define FILE_READ sdfat::O_READ
#define FILE_WRITE (sdfat::O_READ | sdfat::O_WRITE | sdfat::O_CREAT | sdfat::O_APPEND)

Why can't I use the FILE_APPEND constant in order to add new content at the end of the file instead of overwriting it? It's the only error that prevents my code to be compiled.

Thanks and best regards!

Does the same code compile in the regular IDE with the same board selected ?

Changing to Arduino Uno I first got the question if I want to install the AVR boards (I clicked yes). Then the boards are installed:

When I try to build the code I get the following error message:

Alternatives for SD.h: []
  -> candidates: []
Using library SPI at version 1.0 in folder: C:\Users\myUser\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\SPI 
Compilation error: Error: 2 UNKNOWN: exit status 1

So: No, the code isn't compiled with another board because the library isn't found, not even after restarting the IDE.

The classic Arduino IDE comes with a collection of popular official libraries pre-installed. We're used to those libraries always being available, and many tutorials and documentation also assume this. The SD library is one of these.

Arduino IDE 2.x does not currently come with any libraries pre-installed. So you must install any libraries required by your sketch.

That is easily done using Library Manager. Please do this:

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE's menus. This will open Library Manager from the IDE's side bar.
  2. In the "Filter your search" field, type sd.
  3. Scroll down through the list of search results until you see "SD by Arduino, SparkFun". Click on it.
  4. Click the Install button.
  5. Wait for the library installation to finish.

Now try compiling your sketch again.

So now you might wonder why you got different results when you had an ESP8266 board selected. The reason is because boards platforms authors can provide a collection of "platform bundled libraries". These libraries are only accessible when you have a board of that platform selected from the Arduino IDE's Tools > Board menu. The esp8266 boards platform provides a modified version of the SD library written specifically for the ESP8266 architecture. The Arduino AVR Boards platform of the Uno on the other hand does not bundle the SD library because the standard official SD library works just fine for the AVR boards.

The platform bundled libraries generally try to provide a completely compatible API to the standard libraries. For this reason, people are often not even aware that different libraries are being used from one board to another. However, sometimes there are differences. This might result in a sketch that is written for one version of the library not compiling when used with another version.

Thank you for this very detailed information. I knew there are different libraries for different board types, but I didn’t know that the IDE 2.0 doesn’t have any preinstalled - I will keep that in mind for my future work with AVR boards.
Actually this wasn’t the original Problem, which was about why the constant FILE_APPEND isn’t declared although it seems to be defined in the ESP8266‘s SD.h library (I don’t understand the code after the #define statement with the brackets). Do you have an explanation for this?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.