Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I'm using Arduino 1.0

My issue is in a header file being included from my .ino file. This macro works properly in the .ino file and I can't figure out why its not working in the header file.

#define BIT_SET(p,b)                (p |= (1<<b))
// heres the usage of the macro
BIT_SET(CMD_LEDS, SET_ADVANCE_LED);

The error:

COI.h:281: error: lvalue required as left operand of assignment

Any thoughts?

EDIT: I'm an idiot and was trying to set a bit on a defined value...

share|improve this question
2  
What and where is the definition of CMD_LEDS and SET_ADVANCE_LED (particularly the former)? – Kevin Vermeer Dec 31 '11 at 2:57
2  
Also, rather than defining your own BIT_SET macro, consider using the ordinary _BV() macro and friends to be compatible with other AVR code and familiar to other programmers. See the documentation, FAQ entry, and sfr_defs.h source on nongnu.org/avr-libc for more info. – Kevin Vermeer Dec 31 '11 at 3:02
Aghhh thanks so much Kevin. CMD_LEDS is a define statement... it should have been LEDS_STATE which is a uint8_t. Wow, need some sleep I guess. – Michael Dillon Dec 31 '11 at 3:03
And will do, thanks so much. Wish I could check mark you up as helping me out. – Michael Dillon Dec 31 '11 at 3:05
1  
Without knowing the answer to that comment, it was only speculation and a request for clarification, which should be a comment. I might write an answer about the many varieties of lvalue required errors later, but for now I'm signing off. Glad I could finish the day by helping somebody! – Kevin Vermeer Dec 31 '11 at 3:12

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.