Skip to content

Commit 01710fd

Browse files
committed
Suppress unused warnings for logged variables
1 parent 2a320df commit 01710fd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ESP32RotaryEncoder.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
#endif
2222
#endif
2323

24+
#if __cplusplus >= 201703L
25+
#define MAYBE_UNUSED [[maybe_unused]]
26+
#elif defined( __GNUC__ ) || defined( __clang__ )
27+
#define MAYBE_UNUSED __attribute__((unused))
28+
#else
29+
#define MAYBE_UNUSED
30+
#endif
31+
2432
RotaryEncoder::RotaryEncoder( uint8_t encoderPinA, uint8_t encoderPinB, int8_t buttonPin, int8_t vccPin, uint8_t encoderSteps )
2533
: encoderPinA{ encoderPinA },
2634
encoderPinB{ encoderPinB },
@@ -258,7 +266,7 @@ bool RotaryEncoder::buttonPressed()
258266
}
259267

260268
bool wasPressed;
261-
unsigned long duration;
269+
MAYBE_UNUSED unsigned long duration;
262270

263271
portENTER_CRITICAL( &mux );
264272
wasPressed = buttonPressedFlag;
@@ -279,7 +287,7 @@ bool RotaryEncoder::encoderChanged()
279287
}
280288

281289
bool hasChanged;
282-
long value;
290+
MAYBE_UNUSED long value;
283291

284292
portENTER_CRITICAL( &mux );
285293
hasChanged = encoderChangedFlag;

0 commit comments

Comments
 (0)