FastLED 3.10.10
Loading...
Searching...
No Matches
cstddef.h
Go to the documentation of this file.
1#pragma once
2
4// FastLED Standard Definition Types (stddef.h equivalents)
5//
6// Provides size_t, ptrdiff_t, max_align_t, and offsetof macro.
8
9// Let the toolchain's real size/ptrdiff guards own the global declarations.
10// This also handles system headers included before or after FastLED headers.
11// IWYU pragma: begin_keep
12#include <stddef.h>
13// IWYU pragma: end_keep
14
15namespace fl {
16
17// FastLED equivalent of std::nullptr_t
18typedef decltype(nullptr) nullptr_t;
19
20// FastLED equivalent of std::size_t and std::ptrdiff_t
23
24// FastLED equivalent of std::max_align_t
25// Use union approach (like standard library implementations) for fast compilation
26// Template-based selection to handle platforms where long double == double
27namespace detail {
28 // Union variant with long double (for platforms with distinct long double like x86/x64)
29 typedef union {
30 long long ll;
31 long double ld;
32 void* p;
34
35 // Union variant without long double (for ARM/AVR where long double == double)
36 typedef union {
37 long long ll;
38 double d;
39 void* p;
41}
42
43// Template selector - automatically chooses correct variant at compile time
44template <bool UseLD>
48
49template <>
53
54// Select appropriate union based on whether long double is distinct from double
55typedef typename max_align_selector<(sizeof(long double) > sizeof(double))>::type max_align_t;
56
57} // namespace fl
58
59// FastLED equivalent of offsetof macro (stddef.h)
60// Computes byte offset of a member within a struct/class at compile time
61// Uses the compiler builtin independently of the system offsetof macro.
62#define FL_OFFSETOF(type, member) __builtin_offsetof(type, member)
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_info.h:57
max_align_selector<(sizeof(longdouble)>sizeof(double))>::type max_align_t
Definition cstddef.h:55
::ptrdiff_t ptrdiff_t
Definition cstddef.h:22
::size_t size_t
Definition cstddef.h:21
decltype(nullptr) nullptr_t
Definition cstddef.h:18
Base definition for an LED controller.
detail::max_align_with_ld type
Definition cstddef.h:46
detail::max_align_without_ld type
Definition cstddef.h:51