Arduino.h:107:16: error: expected ';' before '_UART_USB_' #define Serial _UART_USB_

Hi,
after upgrading from IDE 2.2 to 2.3.1 unexpected error on compiling my sketch MY_ESS_22Q216 on GIGA R1, using ArduinoModbus and ArduinoRS485 libraries! I I have had redirected the communication out-/input of RS485 library to Serial1.

In file included from C:\Users\remus\AppData\Local\Temp\arduino\sketches\DE17CE72EF1E5F793179FAC296099874\sketch\my_ESS_22Q216.ino.cpp:1:0:
C:\Users\remus\Documents\Arduino\my_ESS_222Q\my_ESS_22Q216\my_ESS_22Q216.ino: In function 'long unsigned int BmsRead()':
C:\Users\remus\AppData\Local\Arduino15\packages\arduino\hardware\mbed_giga\4.1.1\cores\arduino/Arduino.h:107:16: error: expected ';' before '_UART_USB_'
 #define Serial _UART_USB_
                ^
C:\Users\remus\AppData\Local\Arduino15\packages\arduino\hardware\mbed_giga\4.1.1\cores\arduino/Arduino.h:107:16: note: in definition of macro 'Serial'
 #define Serial _UART_USB_
                ^~~~~~~~~~
Mehrere Bibliotheken wurden für "WiFi.h" gefunden
  Benutzt: C:\Users\remus\AppData\Local\Arduino15\packages\arduino\hardware\mbed_giga\4.1.1\libraries\WiFi
  Nicht benutzt: C:\Users\remus\Documents\Arduino\libraries\WiFiNINA
exit status 1

Compilation error: exit status 1

In the compiler transcript a very special reference to function 'long unsigned int BmsRead()' : the function long unsigned BmsRead() exists (within several #ifdef/#endif sections, which I have specially controlled for typos!

I have also tried to "patch" arduino.h by replacing its #define Serial directive:

#include "Serial.h"
#include "timer.h"
#if defined(SERIAL_CDC)
#define Serial _UART_USB_
#define SerialUSB _UART_USB
#else
// CHG Modification debut MY_ESS_22Q
//#define Serial _UART1_
#define Serial _UART_USB_
// END CHG Modification debut MY_ESS_22Q
#endif
#define Serial1 _UART1_
#define Serial2 _UART2_
#define Serial3 _UART3_
#define Serial4 _UART4_

#if defined(RPC_SERIAL)
#undef Serial
#if __has_include("RPC.h")
#include "SerialRPC.h"
#define Serial SerialRPC
#else
extern ErrorSerialClass ErrorSerial;
#define Serial ErrorSerial
#endif
#endif

which produced same error as above.

As next (intermediate) step, I'm gonna try to compile in Web IDE ...

Any opinions about IDE2.3.1?
Thanks
debut
Daniel Buergi

Addendum 2024-02-17

Web DE yields same compile errors:

Start verifying
In file included from /tmp/arduino-build-D01E70BE83CE11F88F8FC4CBECE6B248/sketch/Untitled_jan16a.ino.cpp:1:0: /tmp/351897165/Untitled_jan16a/Untitled_jan16a.ino: In function 'long unsigned int BmsRead()': /home/builder/.arduino15/packages/arduino/hardware/mbed_giga/4.1.1/cores/arduino/Arduino.h:107:16: error: expected ';' before '_UART_USB_' #define Serial _UART_USB_ ^ /home/builder/.arduino15/packages/arduino/hardware/mbed_giga/4.1.1/cores/arduino/Arduino.h:107:16: note: in definition of macro 'Serial' #define Serial _UART_USB_ ^~~~~~~~~~ Multiple libraries were found for "Wire.h" Used: /home/builder/.arduino15/packages/arduino/hardware/mbed_giga/4.1.1/libraries/Wire Not used: /home/builder/opt/libraries/flexwire_1_2_0 Multiple libraries were found for "WiFi.h" Used: /home/builder/.arduino15/packages/arduino/hardware/mbed_giga/4.1.1/libraries/WiFi Not used: /home/builder/opt/libraries/nina_wi_fi_1_0_1 Not used: /home/builder/opt/libraries/wifi_1_2_7 Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1 Not used: /home/builder/opt/libraries/seeed_arduino_rpcwifi_1_0_7 Not used: /home/builder/opt/libraries/wifinina_1_8_14 Not used: /home/builder/opt/libraries/wifiespat_1_4_3 Not used: /home/builder/opt/libraries/da16200_wi_fi_library_for_arduino_1_1_0 Not used: /home/builder/opt/libraries/indhilib_3_0_5 Multiple libraries were found for "ArduinoECCX08.h" Used: /home/builder/opt/libraries/arduinoeccx08_1_3_8 Not used: /home/builder/opt/libraries/rak5814_atecc608a_1_0_0 Error during build: exit status 1

Addendum #2 2024-02-17
Shortly before the IDE Upgrade I upgraded the mbed_giga package ! Should this post be classified as Hardware GIGA R1 as well ? Sorry!

Hi @debut. Please post your full sketch.

I'll provide instructions you can follow to do that:

  1. Select Tools > Auto Format from the Arduino IDE menus.
    This is done to make the code easier for us to read.
  2. Select Edit > Copy for Forum (Markdown) from the Arduino IDE menus.
  3. In a forum reply here, click on the post composer field.
  4. Press the Ctrl+V keyboard shortcut.
    This will paste the sketch to the post composer.
  5. Move the cursor outside of the code block markup before you add any additional text to your reply.
  6. Repeat the above process if your sketch has multiple tabs.
  7. Click the "Reply" button to post your reply.

When your code requires a library that's not included with the Arduino IDE please post a link to where you downloaded that library from, or if you installed it using Library Manager (Sketch > Include Library > Manage Libraries... in Arduino IDE) then say so and state the full name of the library.


In case you don't want to share your full sketch, it is fine to instead provide a minimal sketch that contains only the code required to reproduce the compilation error.

Did you do this by modifying the library, or only through your sketch code?

Hi @ptillisch,
thanks for the very personal tips! Yes, my sketch is too voluminous to be shared entirely. And yes, the part I posted in my question was (!) minimalistic ...
The good news: my problem is solved, I'll find out how to document this the correct way here!
Explanation:

  • the compilation error, pointing to Arduino.h, resulted from a very simple typo (I somewhen missed the search window of the IDE and (mis)typed so 'Serial' into the code pane, on a code line behind the semicolon, resulting in the posted compilation error information ...

Concerning the ArduinoRS485 library: Yes, I adapted a post in this forum, which told me, how to add the setSerial() function to the library to be able to use the library (together with ArduinoModbus) without a RS485 shield on the GIGA R1 Board. I have documented this in my sketch and I am aware of possible implications of this (I even rolled back my modification temporarily before posting above problem, to be sure they were not tied together with each other!

Thanks again
@debut

1 Like

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