Error compiling, debug.h:17:15: error: expected

Hello All,
First of all thanks for your great support.

Although last time I worked in this code it was working fine, I got an error on compilation, therefore I think is something related with the platformio libraries I got installed or some configuration.

This is the full error:

In file included from C:\Users\Miguel\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Stream.h:25,
                 from C:\Users\Miguel\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/HardwareSerial.h:32,
                 from C:\Users\Miguel\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Arduino.h:288,
                 from C:\Users\Miguel\AppData\Local\Temp\tmpvxy3fvbw:1:
.pio\libdeps\d1_mini\ESP8266SAM\src/debug.h:17:15: error: expected ',' or '...' before numeric constant
   17 | #define debug 0
      |               ^
.pio\libdeps\d1_mini\WiFiManager/WiFiManager.h:99:42: note: in expansion of macro 'debug'
   99 |     void          setDebugOutput(boolean debug);

This is my Platformio.ini

platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed = 115200
upload_speed = 115200
lib_deps =
    earlephilhower/ESP8266Audio @ ^1.6.0
    earlephilhower/ESP8266SAM @ ^1.0
    tzapu/WiFiManager @ ^0.16.0

Any idea what I could do?
I’ve already uninstalled all libraries from platformio and run the build to get just the libraries needed.


Look closely: There is boolean paramter called debug in the function, but the previous macro definition defines debug to 0, so the expanded version looks like

void          setDebugOutput(boolean 0);

which is not valid C++.

Naming a header debug.h, that is contained in this ESP8266SAM is a dangerous thing to do because the name is very generic and the header could already be in some other place.

(EDIT: Which there is: Arduino/debug.h at master · esp8266/Arduino · GitHub)

The easiest thing you can do is to make sure that the #include <ESP8266SAM.h> comes last before any #include <WiFiManager.h> in the code. That way the macro takes effect later.

If that does not help, you can fix it in sourcecode by e.g. renaming the debug.h header (and all references in the ESP8266SAM library code) and the debug macro to something more unique.

An issue was opened in debug.h file creates conflict with core and other libraries · Issue #16 · earlephilhower/ESP8266SAM · GitHub.

Hello @maxgerhardt, Thank you very much for your help and quick response.
I’m not so good at this as I’m learning as I go.

Here are my Include libraries, putting the ESP8266SAM.h at the end doesn’t fix the error

//needed for library
#include "WiFiManager.h"          //
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <EEPROM.h>
#include "PubSubClient.h"
#include <ESP8266WiFi.h>

//Audio libraries
#include "AudioFileSourceICYStream.h"
#include "AudioFileSourceBuffer.h"
#include "AudioGeneratorMP3.h"
#include "AudioGeneratorWAV.h"
#include "AudioGeneratorRTTTL.h"
#include "AudioOutputI2SNoDAC.h"
#include "AudioFileSourcePROGMEM.h"
#include <SD.h>
#include "ESP8266SAM.h"

I’ll analize deeper your suggestion to rename debug header.
Thank you for opening the issue too.

Let me just quickly fork the library so you can test out a fix.

Could you try my fork please. Replace the lib_deps expression in your platformio.ini with

lib_deps =
    earlephilhower/ESP8266Audio @ ^1.6.0
    tzapu/WiFiManager @ ^0.16.0

to use it.

It worked!!! :tada:
Man you are awesome.

I’ll check your fork to see what you did and learn from it.

Thank you very very much for your help :smile:

1 Like