ESP32 WIFI compilation issue - expected unqualified-id before ')' token

Hello, all,
Thank you for maintaining this helpful site.
For the first time I'm using WiFi ESPNow on ESP32. The usage is pretty simple, and the relevant class is brough below. I get an error message - "expected unqualified-id before ')' token"; However, I don't know which line in my code invokes the method in the library. I'm focusing on the processReceivedMessage, which is being invoked by the onReceive event' simply because I had other issues that were solved when I declared rxBufferL as a simple string rather than volatile (I assumed that the event is some kind of interrupt service routine - is it correct?).

I am using Arduino IDE 2.3.4 that is running under Windows 10.

Thank you very much
Yona Gy

#ifndef ESP_NOW_TOP_S
#define ESP_NOW_TOP_S

/**
 * @file
 *
 * EspNowUnicast.ino demonstrates how to transmit unicast ESP-NOW messages with @c WifiEspNow .
 * You need two ESP8266 or ESP32 devices to run this example.
 *
 * Unicast communication requires the sender to specify the MAC address of the recipient.
 * Thus, you must modify this program for each device.
 *
 * The recommended workflow is:
 * @li 1. Flash the program onto device A.
 * @li 2. Run the program on device A, look at serial console for its MAC address.
 * @li 3. Copy the MAC address of device A, paste it in the @c PEER variable below.
 * @li 4. Flash the program that contains A's MAC address onto device B.
 * @li 5. Run the program on device A, look at serial console for its MAC address.
 * @li 6. Copy the MAC address of device B, paste it in the @c PEER variable below.
 * @li 7. Flash the program that contains B's MAC address onto device A.
 */
#include <arduino.h>
#include "WifiEspNow.h"
#include <WiFi.h>

class WENT {
public:
  //    static void printReceivedMessage(const uint8_t mac[WIFIESPNOW_ALEN], const uint8_t* buf, size_t count, void* arg);
  String begin();
  void send(String message);
private:
  uint8_t peerMAC[WIFIESPNOW_ALEN];
} went;

void processReceivedMessage(const uint8_t peerMAC[WIFIESPNOW_ALEN],
                            const uint8_t* buf, size_t count, void* arg) {
  noInterrupts();
  String rxBufferL = "";
  for (byte i = 0; i < count; i++)
    rxBufferL += (char)buf[i];
  
  Serial.print("Station #" + String(stationType));
  Serial.println(": " + rxBufferL);
  interrupts();
}

String WENT::begin() {
//  Serial.println("WENT begin TP 1");
  WiFi.persistent(false);
  WiFi.mode(WIFI_AP);
  WiFi.disconnect();
  WiFi.softAP("ESPNOW", nullptr, 3);
  WiFi.softAPdisconnect(false);
  uint8_t mac[6];
  WiFi.softAPmacAddress(mac);
  Serial.printf("static uint8_t     peer[]{0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X};\n",
                mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  if (!WifiEspNow.begin())
    return ("Error - WifiEspNow begin() failed");
//  Serial.println("WENT begin TP 3");

  WifiEspNow.onReceive(processReceivedMessage, nullptr);
//  Serial.println("WENT begin TP 4");

  if (!WifiEspNow.addPeer(peerMAC))
    return ("Error - WifiEspNow addPeer() failed");
  return "WifiEspNow Passed init and association";
}

void WENT::send(String txMessage) {
  uint8_t count = sizeof(txMessage);
  char msg[count + 1];  //as 1 char space for null is also required
  strcpy(msg, txMessage.c_str());
  msg[count] = '\0';
  WifiEspNow.send(peerMAC, reinterpret_cast<const uint8_t*>(msg), count);
  delay(1000);
}
#endif  // ESP_NOW_TOP_S

The error message:

In file included from C:\Users\USER\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.3-cfea4f7c-v1\esp32c3/include/esp_eth/include/esp_eth_driver.h:18,
                 from C:\Users\USER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFiGeneric.h:37,
                 from C:\Users\USER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFiSTA.h:30,
                 from C:\Users\USER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFi.h:34,
                 from E:\Current\Tractor\SWtractorCombined_V1.0\src\wifiEspNow\WifiEspNow.h:10,
                 from E:\Current\Tractor\SWtractorCombined_V1.0\src\wifiEspNow\EspNowTop.h:23,
                 from E:\Current\Tractor\SWtractorCombined_V1.0\TractorDecV7.x.h:88,
                 from E:\Current\Tractor\SWtractorCombined_V1.0\SWtractorCombined_V1.0.ino:33:
C:\Users\USER\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.3-cfea4f7c-v1\esp32c3/include/esp_eth/include/esp_eth_phy.h:207:25: error: expected unqualified-id before ')' token
  207 |     esp_err_t (*loopback)(esp_eth_phy_t *phy, bool enable);
      |                         ^

What version of ESP board support do you use?

Thanks for posting the error message as code, which helpfully positions the ^ on the last line at the column under the appropriate )

The error is not from invoking a method; while trying to compile your sketch, one of the headers has -- at that moment -- a faulty declaration.

Reading the error message, you have a stack of "In file included from". Reading that from the bottom up, you can focus on

SWtractorCombined_V1.0\src\wifiEspNow\WifiEspNow.h:10,
SWtractorCombined_V1.0\src\wifiEspNow\EspNowTop.h:23,
SWtractorCombined_V1.0\TractorDecV7.x.h:88,
SWtractorCombined_V1.0\SWtractorCombined_V1.0.ino:33:
  • the last line is your sketch: the .ino file has the same name as the directory that contains it. On line 33, it includes
  • TractorDecV7.x.h: on line 88, that includes
  • EspNowTop.h. Based on the include guards, that's the file you posted. And by eye, that looks like around line 23
  • #include "WifiEspNow.h"
    

That's code in your sketch. On line 10 of your WifiEspNow.h, you're including WiFi.h. You can see from the paths that the code is now in the board platform's libraries and includes (version 3.1.1). A few more steps and the last one is that esp_eth_driver.h includes esp_eth_phy.h, and that file contains the line the compiler doesn't like. Looking at the code, it's declaring one of a whole bunch of function pointers in struct esp_eth_phy_s for Ethernet.

The error says "expected unqualified-id"; so apparently at this point, loopback is not what it appears to be in the code. Maybe now it is a macro that turns into something else?

WiFi.h is used quite often. Looking back at that stack of includes, it's WiFiGeneric.h that has the conditional

#if CONFIG_ETH_ENABLED
#include "esp_eth_driver.h"
#endif

So if you try an otherwise empty sketch

#define CONFIG_ETH_ENABLED 1
#include <WiFi.h>

esp_eth_phy_s eep;

void setup() {}

void loop() {}

Does that compile OK? But maybe a better question: if you're using ESP-Now, are you actually also using Ethernet?

Which board are you using? I picked the first board on the giant list for esp32 that looked like it has Ethernet: LilyGo T-ETH-Lite. And that empty sketch also compiled OK, without the #define.

Hello, B707,
Thank you for your response. I am using version 3.1.1.

regards
Yona

Dear Kenb4,
Thank you very much for your detailed response. I will answer your questions one by one:

  1. Compilation of the empty sketch passed with no errors.
  2. I am not using ethernet. This is a communication link between two isolated stations.
  3. The list is indeed giant' and there is no search tool that I am aware of. I am using XIAO_ESP32_C3, which is pretty low on the list.

For further analysis I brought back the example INO. It was compiled faultlessly. I tried to block the contents of the methods of EspNowTop.h, but the error still appeared; only blocking the inclusion of the WIFI.H was helpful.

Thank you
Tona

I only see XIAO_ESP32C3 -- one underscore, not two. (You can click the board name in the toolbar and "Select other board and port...". The resulting dialog has search.)

Does the word loopback appear in your code anywhere? With that board, you can deliberately break the mostly empty sketch like this

#define loopback something;  // <-- added this line
#include <WiFi.h>

esp_eth_phy_s eep;

void setup() {}

void loop() {}

to get your exact error. If you instead

#undef CONFIG_ETH_ENABLED  // <-- add this line
#include <WiFi.h>

esp_eth_phy_s eep;  // this will fail, because there's no Ethernet

void setup() {}

void loop() {}

So you can try adding that #undef near the top of your sketch, certainly before #include "TractorDecV7.x.h" and <WiFi.h> if you also have it there; to consistently disable Ethernet at least as far as your sketch is concerned.

Indeed!!! I've had a definition of a flag named "loopback". After renaming it to "loopbackMode" the error DISAPPEARED!! Thank you so much!!