Inexplicable error in #define

I made some minor changes in a sketch that was running pretty fine and now I get this error, never seen before, when compiling:

D:\Arduino\Sketches\_grafiica\myButtons\myButtons.ino:55:17: error: lvalue required as left operand of assignment
 #define TEMPBTN 0
                 ^
D:\Arduino\Sketches\_grafiica\myButtons\myButtons.ino:175:51: note: in expansion of macro 'TEMPBTN'
     if (lastButton && btns[lastButton - 1].type = TEMPBTN) { ...

Then only thing I changed in the code, somehow related to the error, was to rename 'TMPBTN' to 'TEMPBTN'.
The row is in this section:

// define items type
#define TEMPBTN 0
#define PUSHBTN 1
#define CHECK 2

I tried to rename it back, to move the define before and after the original posizion, to delete and recreate it, to save, quit and reload...nothing, that row always results wrong as if the name 'TEMPBTN' is not there.
I'm going crazy
Thanks

post the code in highlighted area after clicking </>

I think you meant to use '==' (comparison) rather than '=' assignment.

The "error: lvalue required" is telling you that you can't write into "btns[lastButton - 1].type". Perhaps it is declared 'const'.

1 Like

I don't know if I am only dumb or even blind :cry:
After years I still do these stupid errors !
Thank johnwasser

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