[SOLVED] Code suddenly gives error "Error compiling of board Arduino Mega..."

Hi,

I am working on an IOT project with Blynk.
I am using a WW5500 Ethernet module, it works fine with the Blynk test for enthernet2(it connects to the server).
Yesterday my code compiled fine, but suddenly it gives this error.

Yesterday my code compiled fine, but suddenly it gives an errorArduino:1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board:"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from sketch\Arduino_Ethernet2.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:40:14: error: expected unqualified-id before numeric constant

 #define HIGH 0x1

              ^

C:\Users\Isaak\Documents\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'

 #define CLOSED HIGH

                ^~~~

C:\Users\Isaak\Documents\Arduino\libraries\Ethernet2\src/utility/w5500.h:99:24: note: in expansion of macro 'CLOSED'

   static const uint8_t CLOSED      = 0x00;

                        ^~~~~~

In file included from C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h:16:0,

                 from C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/BlynkApiArduino.h:14,

                 from C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Adapters/BlynkEthernet.h:24,

                 from C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEthernet2.h:20,

                 from C:\Users\Isaak\Desktop\Arduino_Ethernet2\Arduino_Ethernet2.ino:123:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h: In instantiation of 'void BlynkParam::add_multi(T) [with T = float (*)(); Args = {}]':

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h:81:9:   required from 'void BlynkApi<Proto>::virtualWrite(int, Args ...) [with Args = {float (*)()}; Proto = BlynkProtocol<BlynkArduinoClientGen<Client> >]'

C:\Users\Isaak\Desktop\Arduino_Ethernet2\Arduino_Ethernet2.ino:130:40:   required from here

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:112:9: error: no matching function for call to 'add(float (*&)())'

         add(last);

         ^~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:231:10: note: candidate: void BlynkParam::add(int) <near match>

     void BlynkParam::add(int value)

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:231:10: note:   conversion of argument 1 would be ill-formed:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:239:10: note: candidate: void BlynkParam::add(unsigned int) <near match>

     void BlynkParam::add(unsigned int value)

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:239:10: note:   conversion of argument 1 would be ill-formed:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:247:10: note: candidate: void BlynkParam::add(long int) <near match>

     void BlynkParam::add(long value)

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:247:10: note:   conversion of argument 1 would be ill-formed:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:255:10: note: candidate: void BlynkParam::add(long unsigned int) <near match>

     void BlynkParam::add(unsigned long value)

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:255:10: note:   conversion of argument 1 would be ill-formed:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:263:10: note: candidate: void BlynkParam::add(long long int) <near match>

     void BlynkParam::add(long long value)  // TODO: this currently adds just a long

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:263:10: note:   conversion of argument 1 would be ill-formed:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:271:10: note: candidate: void BlynkParam::add(long long unsigned int) <near match>

     void BlynkParam::add(unsigned long long value) // TODO: this currently adds just a long

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:271:10: note:   conversion of argument 1 would be ill-formed:

exit status 1

Fout bij het compileren voor board Arduino Mega or Mega 2560



Dit rapport zou meer informatie bevatten met
"Uitgebreide uitvoer weergeven tijden compilatie"
optie aan in Bestand -> Voorkeuren.

whole sketch:

//U8lib
#include <U8glib.h>
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_FAST);
void draw() {
  u8g.setFont(u8g_font_unifont);
  u8g.setPrintPos(0, 20);
  u8g.print("Hello World!");
}
void U8glib_print() {
  u8g.firstPage();
  do {
    draw();
  } while ( u8g.nextPage() );
}

// KEYPAD
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', '4'},
  {'5', '6', '7', '8'},
  {'9', 'A', 'B', 'C'},
  {'D', 'E', 'F', 'G'}
};
byte rowPins[ROWS] = {29, 27, 25, 23};
byte colPins[COLS] = {22, 24, 26, 28};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
char Keypad_return() {
  char customKey = customKeypad.getKey();
  if (customKey) {
    return customKey;
  }
}
bool Keypad_ask(char ask) {
  char customKey = customKeypad.getKey();
  if (customKey == ask) {
    return LOW;
  }
  else {
    return HIGH;
  }
}



//DHT
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 48
#define DHTTYPE DHT11
DHT_Unified dht(DHTPIN, DHTTYPE);

float DHT_return(char selector = 'H') {
  sensors_event_t event;
  dht.temperature().getEvent(&event);
  if ( selector == 'H') {
    if (isnan(event.temperature)) {
    }
    else {
      return event.temperature;
    }
  }
  else if ( selector == 'T') {
    sensors_event_t event;
    dht.humidity().getEvent(&event);
    if (isnan(event.relative_humidity)) {
    }
    else {
      return event.relative_humidity;
    }
  }
}

//BH1750
#include <BH1750.h>
BH1750 lightMeter;
float BH1750_return() {
  return lightMeter.readLightLevel() * 10;
}

//BMP
#include <Wire.h>
#include "SparkFunBME280.h"
BME280 BMP;
float BMP_return(char selector = 'T') {
  if (selector == 'T') {
    return BMP.readTempC();
  } else if (selector == 'F') {
    return BMP.readTempF();
  } else if (selector == 'H') {
    return BMP.readFloatHumidity();
  } else if (selector == 'P') {
    return BMP.readFloatPressure();
  }
}

//RELAY
byte relay[4] = {34, 35, 36, 37};

// EEPROM
#include <EEPROM.h>
#define SETTINGS_AMOUNT 1
byte currentSettings[SETTINGS_AMOUNT];

void updateSettings() {
  for (int i = 0; i < SETTINGS_AMOUNT; i++) {
    EEPROM.update(i, currentSettings[i]);
  }
}
void getSettings() {
  for (int i = 0; i < SETTINGS_AMOUNT; i++) {
   currentSettings[i] = EEPROM.read(i);
  }
}

//BLYNK
#include <SPI.h>
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>
#define BLYNK_PRINT Serial
BlynkTimer timer;
char auth[] = ""; //I removed it (but the right one was here!)

void myTimerEvent() {
  Blynk.virtualWrite(V10, BMP_return('T'));
  Blynk.virtualWrite(V12, BH1750_return);
}


void setup() {
  Serial.begin(9600);
  Blynk.begin(auth);
  timer.setInterval(1000L, myTimerEvent);

  dht.begin();
  lightMeter.begin();
  BMP.setI2CAddress(0x76);
  if (BMP.beginI2C() == false) Serial.println("BMP connect failed");

  getSettings();
}

void loop() {
  Blynk.run();
}

It looks like it has to do with the library, but i didn’t mess with it.
I recompiled it many times (some other topics suggested that it might work).
I deleted and reinstalled both Eternet2 and Blynk libraries.
I also reinstaled the arduino boards…
But all without success.

If anyone knows how to solve this issue, i would really appreciate it!

update: in attachment you can find a verbose output.

Isaak

verbose output.txt (274 KB)

In the Ethernet2 library is the line:

static const uint8_t CLOSED      = 0x00;

But in the Keypad library, CLOSED is defined as HIGH

 #define CLOSED HIGH

And in the Arduino core, HIGH is defined as 0x1

 #define HIGH 0x1

The end result is that the line in the Ethernet2 library looks like:

static const uint8_t 0x1  = 0x00;

That does not make syntactic sense.

It might work if you #include Ethernet2 (your // BLYNK section) BEFORE Keypad.

johnwasser:
It might work if you #include Ethernet2 (your // BLYNK section) BEFORE Keypad.

Your solution worked, after I put the "//BLYNK" section on top the sketch compiled just fine!

Thank you so much!
Isaak

cheered too early…

it worked fine, but after 2 uploads (this project is still a work in progress) it stoped working again.

getting this error message:

Arduino:1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board:"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"





















In file included from C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h:16:0,

                 from C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/BlynkApiArduino.h:14,

                 from C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Adapters/BlynkEthernet.h:24,

                 from C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEthernet2.h:20,

                 from C:\Users\Isaak\Documents\Arduino\Projects\Arduino base station\AMS_V1\AMS_V1.ino:3:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h: In instantiation of 'void BlynkParam::add_multi(T) [with T = float (*)(); Args = {}]':

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h:81:9:   required from 'void BlynkApi<Proto>::virtualWrite(int, Args ...) [with Args = {float (*)()}; Proto = BlynkProtocol<BlynkArduinoClientGen<Client> >]'

C:\Users\Isaak\Documents\Arduino\Projects\Arduino base station\AMS_V1\AMS_V1.ino:9:40:   required from here

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:112:9: error: no matching function for call to 'add(float (*&)())'

         add(last);

         ^~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:231:10: note: candidate: void BlynkParam::add(int) <near match>

     void BlynkParam::add(int value)

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:231:10: note:   conversion of argument 1 would be ill-formed:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:239:10: note: candidate: void BlynkParam::add(unsigned int) <near match>

     void BlynkParam::add(unsigned int value)

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:239:10: note:   conversion of argument 1 would be ill-formed:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:247:10: note: candidate: void BlynkParam::add(long int) <near match>

     void BlynkParam::add(long value)

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:247:10: note:   conversion of argument 1 would be ill-formed:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:255:10: note: candidate: void BlynkParam::add(long unsigned int) <near match>

     void BlynkParam::add(unsigned long value)

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:255:10: note:   conversion of argument 1 would be ill-formed:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:263:10: note: candidate: void BlynkParam::add(long long int) <near match>

     void BlynkParam::add(long long value)  // TODO: this currently adds just a long

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:263:10: note:   conversion of argument 1 would be ill-formed:

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:271:10: note: candidate: void BlynkParam::add(long long unsigned int) <near match>

     void BlynkParam::add(unsigned long long value) // TODO: this currently adds just a long

          ^~~~~~~~~~

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:271:10: note:   conversion of argument 1 would be ill-formed:

exit status 1

Fout bij het compileren voor board Arduino Mega or Mega 2560



Dit rapport zou meer informatie bevatten met
"Uitgebreide uitvoer weergeven tijden compilatie"
optie aan in Bestand -> Voorkeuren.

with this code:

#include <SPI.h>
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>
#define BLYNK_PRINT Serial
BlynkTimer timer;
char auth[] = ""; //I removed it (but the right one was here!)

void myTimerEvent() {
  Blynk.virtualWrite(V12, BH1750_return);

}


//U8lib
#include <U8glib.h>
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_FAST);
void draw() {
  u8g.setFont(u8g_font_unifont);
  u8g.setPrintPos(0, 20);
  u8g.print("Hello World!");
}
void U8glib_print() {
  u8g.firstPage();
  do {
    draw();
  } while ( u8g.nextPage() );
}


//DHT
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 48
#define DHTTYPE DHT11
DHT_Unified dht(DHTPIN, DHTTYPE);

float DHT_return(char selector = 'H') {
  sensors_event_t event;
  dht.temperature().getEvent(&event);
  if ( selector == 'H') {
    if (isnan(event.temperature)) {
    }
    else {
      return event.temperature;
    }
  }
  else if ( selector == 'T') {
    sensors_event_t event;
    dht.humidity().getEvent(&event);
    if (isnan(event.relative_humidity)) {
    }
    else {
      return event.relative_humidity;
    }
  }
}


//BH1750
#include <BH1750.h>
BH1750 lightMeter;
float BH1750_return() {
  return lightMeter.readLightLevel() * 10;
}
/*
  //BMP
  #include <Wire.h>
  #include "SparkFunBME280.h"
  BME280 BMP;
  float BMP_return(char selector = 'T') {
  if (selector == 'T') {
    return BMP.readTempC();
  } else if (selector == 'F') {
    return BMP.readTempF();
  } else if (selector == 'H') {
    return BMP.readFloatHumidity();
  } else if (selector == 'P') {
    return BMP.readFloatPressure();
  }
  }
*/
/*
// KEYPAD
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', '4'},
  {'5', '6', '7', '8'},
  {'9', 'A', 'B', 'C'},
  {'D', 'E', 'F', 'G'}
};
byte rowPins[ROWS] = {29, 27, 25, 23};
byte colPins[COLS] = {22, 24, 26, 28};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
char Keypad_return() {
  char customKey = customKeypad.getKey();
  if (customKey) {
    return customKey;
  }
}
bool Keypad_ask(char ask) {
  char customKey = customKeypad.getKey();
  if (customKey == ask) {
    return LOW;
  }
  else {
    return HIGH;
  }
}*/

//RELAY
byte relay[4] = {34, 35, 36, 37};

// EEPROM
#include <EEPROM.h>
#define SETTINGS_AMOUNT 1
byte currentSettings[SETTINGS_AMOUNT];

void updateSettings() {
  for (int i = 0; i < SETTINGS_AMOUNT; i++) {
    EEPROM.update(i, currentSettings[i]);
  }
}
void getSettings() {
  for (int i = 0; i < SETTINGS_AMOUNT; i++) {
    currentSettings[i] = EEPROM.read(i);
  }
}




void setup() {
  Serial.begin(9600);
  Blynk.begin(auth);
  timer.setInterval(1000L, myTimerEvent);

  dht.begin();
  lightMeter.begin();
  // BMP.setI2CAddress(0x76);
  // if (BMP.beginI2C() == false) Serial.println("BMP connect failed");

  getSettings();
}

void loop() {
  Blynk.run();
}

Isaak

         add(last);

Is 'last' a function that you meant to call? That would be "last()".

sorry, I don't really get what you mean...
I don't think I'm using a function called last() or add(last) in my sketch.
It might be in one of the libraries tho.

Isaak

The virtualWrite() function doesn't have an overload that takes a function pointer.

Blynk.virtualWrite(V12, BH1750_return);

Perhaps you meant to write:

Blynk.virtualWrite(V12, BH1750_return());

Thx gfvalvo, it compiled!
I don't understand how I did not see that...

gfvalvo:
The virtualWrite() function doesn't have an overload that takes a function pointer.

That is probebly the reason that the error showed that there whas something wrong with the parameter.

C:\Users\Isaak\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkParam.h:239:10: note:   conversion of argument 1 would be ill-formed:[color=#222222][/color]

Thanks again, I can go on with my project now!
Isaak

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