FastLED 3.9.15
Loading...
Searching...
No Matches
undef.h
Go to the documentation of this file.
1// Note: intentionally no #pragma once — this file is designed to be re-includable.
2// It is a macro-reset header, not a definitions header. Including it multiple times
3// is idempotent and correct: it cleans up any macros active at the point of inclusion.
4// Re-inclusion is needed because platform headers may re-define min/max/abs/etc. after
5// an earlier cleanup (e.g. the fl/system/arduino.h cleanup that runs before platform headers,
6// and the fl/stl/math.h cleanup that runs after them).
7
8#include "fl/stl/has_include.h" // IWYU pragma: keep
9
10#if FL_HAS_INCLUDE(<stdlib.h>)
11// IWYU pragma: begin_keep
12#include <stdlib.h>
13// IWYU pragma: end_keep // This will sometimes define macros like abs, min, max, etc.
14#endif
15
16// Undefine common macros that conflict with FastLED function/method names
17// Arduino and many platform headers define min/max/abs/round as function-like macros,
18// which prevents us from declaring functions or member functions with these names.
19//
20// Include this header immediately before any code that declares functions named
21// min, max, abs, round, etc. to prevent macro expansion issues.
22//
23// Usage:
24// #include "fl/stl/undef.h" // Before declaring min/max/abs functions
25// static T min() { ... }
26// static T max() { ... }
27
28#ifdef min
29#undef min
30#endif
31
32#ifdef max
33#undef max
34#endif
35
36#ifdef abs
37#undef abs
38#endif
39
40#ifdef round
41#undef round
42#endif
43
44#ifdef radians
45#undef radians
46#endif
47
48#ifdef degrees
49#undef degrees
50#endif
51
52#ifdef map
53#undef map
54#endif