Error Message: error: expected unqualified-id before numeric constant

Code:

#include <SevenSeg.h>

SevenSeg disp(11,7,3,5,6,10,2);

const int numOfDigits=4;
int digitPins[numOfDigits]={12,9,8,13};

void setup() {
  
  disp.setDigitPins(numOfDigits, digitPins);

}  

void loop() {

    disp.write(13.28);

}

Error Message:

In file included from C:\Users\stier\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\4.0.8\cores\arduino/api/String.h:29:0,
                 from C:\Users\stier\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\4.0.8\cores\arduino/api/IPAddress.h:24,
                 from C:\Users\stier\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\4.0.8\cores\arduino/api/ArduinoAPI.h:30,
                 from C:\Users\stier\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\4.0.8\cores\arduino/Arduino.h:27,
                 from C:\Users\stier\AppData\Local\Temp\arduino\sketches\FF3F1DDE54DD009E29D35E5393F4662F\sketch\sketch_oct15a.ino.cpp:1:
C:\Users\stier\OneDrive\Dokumente\Arduino\libraries\SevenSeg/SevenSeg.h:91:9: error: expected unqualified-id before numeric constant
     int _B;
         ^
C:\Users\stier\OneDrive\Dokumente\Arduino\libraries\SevenSeg/SevenSeg.h:92:9: error: expected unqualified-id before numeric constant
     int _C;
         ^

exit status 1

Compilation error: exit status 1

My problem is that when i verify this code with the arduino mega 2560 it runs perfectly fine, but when I verify it on the nano rp2040 connect it gives me that error message.

What can I do to make it work on the Nano and what is the problem?

That's a bug in the SevenSeg library: the identifiers _B and _C are reserved. Identifiers - cppreference.com

Identifiers that appear as a token or preprocessing token (i.e., not in user-defined-string-literal like operator ""id) of one of the following forms are reserved:

  • identifiers with a double underscore anywhere;
  • identifiers that begin with an underscore followed by an uppercase letter;
  • in the global namespace, identifiers that begin with an underscore.

This has been raised as an issue on GitHub: _B and _C fields collide with esp-idf's newlib's ctype.h · Issue #10 · sigvaldm/SevenSeg · GitHub
But there's no response from the owner, and there has been no activity for 6 years, so I would recommend using a better seven segment display library.

2 Likes

ok can you recommand one?

IDE 2.x and it works on the Mega 2560 but not on the Nano rp2040 connect.

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