Weird compilation Arduino Library error

Anyone run into this compilation error with their giga and giga display?

Users/xxxxxxxx/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.1.1/cores/arduino/Arduino.h:107:16: error: 'UART_USB' does not name a type
#define Serial UART_USB

Any pointers would be greatly appreciated!! cheers, Giles and the sheep

Could you show your code please?

sorry it's over 1500 lines long so I didn't think that would be helpful...

I have run into errors like this and usually has to do with missing a ; at the end of a line...

  Serial.print("abcd")
  Serial.print("xyz");

In this case it was a bit better

C:\Users\kurte\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\kurte\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_
                ^~~~~~~~~~

It would take some experimenting around to reproduce that one, but I have seen it several times and often due to ; missing or error in previous line

Kurt - brilliant - thank you - I've got about 100 Serial.print lines so I'm going to have a good dive in and check every single one - I've been integrating NTP time and Flash storage routines. Thank you for taking the time to comment on this post - I'm really not that experienced in programming but my code is getting quite extensive - especially with the LVGL integration. cheers, Giles

1 Like

Final solution:

This turned out not to be a typo in the code but to do with the location of declaring variables, which is a bit odd.

My code is split into ten .ino pages and a couple of .h pages. This is to keep things neat.
I had a block of bools being declared at the top of one of the .ino pages and they were not being incorporated at compilation time.
I moved this block into the main .ino page between the setup() and the loop() and now it compiles just fine.

Anyone got any thoughts on why this might be? I thought you could declare variables wherever you wanted and it wouldn't make any difference.

Incidentally, this is the procedure I used to check my code:
search for ( character and ) character and make sure the quantity of these match
same for { and }
same for /* and */

Dump the entire code into a single .txt file and cat it through grep -v ";"$ to find all the lines that have a ; at the end and removing those. This led me to a new approach of only using comments on their own line preceeded with a // as you can clear out your comments by piping the above through a grep -v "//" also. This really worked well for being able to read the structure of the code and rapidly spot any problems.

More likely they were being declared at some point after their first use. The .ino files get concatenated into one file before compilation, starting with the .ino with the same name as the sketch, followed by the remainder in sorted (alphabetical?) order.

1 Like

that will teach me to tidy my file names!