Issues running examples with Incin

Hi,

I´m trying to familiarize myself with the Arduino GigaDisplay by running through the examples.

I´ve struck an issue with the ArduinoLogo.ino. After creating a .bin file of my choosing, loading the sketch prompts:

error: incomplete universal character name \U
".text\n" \

As I see it, it´s likely an issue with my file domain

INCBIN(test, "C:\USER\Downloads\test.bin");

but I can´t figure out what exactly the root cause is.

Any help is greatly appreciated!

Welcome to the forum.

Do you have a file "test.bin" ?
Where is it located ?

Thank you!

I have a file called "test.bin", located

C:\USER\Downloads

Hi @vatsugo. In the Arduino Programming Language/C++, the backslash character has a special significance. It signifies the start of an "escape sequence":

https://en.cppreference.com/w/cpp/language/escape

This means that the Windows style use of backslash as a path separator is problematic as the compiler sees things like the "\U" in the path as an escape sequence rather than simply the character \ followed by the character U.

One way to deal with this is to escape the backslash itself:

INCBIN(test, "C:\\USER\\Downloads\\test.bin");

The \\ escape sequence is equivalent to the \ character.

However, this can sometimes get confusing because in cases where a string is interpreted multiple times, you must add an additional level of escaping for each processing layer, leading to unpleasant things like this (or worse):

INCBIN(test, "C:\\\\USER\\\\Downloads\\\\test.bin");

For this reason, it is best to instead use the POSIX compliant slash path separator / whenever possible. Although there might be some rare edge cases where the Windows style backslash is required in paths, the slash is almost always supported.

So please change that line to this and then try again:

INCBIN(test, "C:/USER/Downloads/test.bin");

Hi @ptillisch. I had suspected the double back-slash could solve it, but encountered the issue you mentioned which would require several backslashes.

I just tested your suggestion of using /, and it worked! Many thanks for the quick help!

You are welcome. I'm glad it is working now.

Regards,
Per