Skip to content

Commit

Permalink
Adding parenthesis around 'bitvalue' allowing correct macro expansion
Browse files Browse the repository at this point in the history
when using with ternary operator such as bitWrite(value, bit, some_computed_value == 5 ? 1: 0);
  • Loading branch information
MCUdude committed Jan 19, 2023
1 parent e16f14c commit 811b516
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void yield(void);
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitToggle(value, bit) ((value) ^= (1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit))

// avr-libc defines _NOP() since 1.6.2
#ifndef _NOP
Expand Down

0 comments on commit 811b516

Please sign in to comment.