Minimal demo showing how C++26 reflection enables automatic inspector/serialization for ECS components without macros.
- GCC trunk (with reflection support merged Jan 2026)
- Linux (tested on Ubuntu)
# Install dependencies
sudo apt install build-essential libgmp-dev libmpfr-dev libmpc-dev flex bison
# Clone GCC trunk
git clone git://gcc.gnu.org/git/gcc.git gcc-trunk
cd gcc-trunk
# Build (out-of-source required)
mkdir build && cd build
../configure --prefix=$HOME/gcc-trunk-install \
--enable-languages=c,c++ \
--disable-multilib \
--disable-bootstrap
make -j$(nproc)
make installBuild takes ~10-45 minutes depending on hardware.
cd ecs_reflection_demo
$HOME/gcc-trunk-install/bin/g++ -std=c++26 -freflection main.cpp -o demo
./demo>>> INSPECTOR VIEW <<<
=== Transform ===
[vec3] position: [10.00, 5.00, -3.00]
[vec3] rotation: [0.00, 45.00, 0.00]
[vec3] scale: [1.00, 1.00, 1.00]
=== RigidBody ===
[float] mass: 75.000
[float] drag: 0.500
[float] angular_drag: 0.050
[bool] use_gravity: true
[bool] is_kinematic: false
...
| Syntax | Purpose |
|---|---|
^^Type |
Reflect on a type |
[:refl:] |
Splice reflection back to code |
std::meta::nonstatic_data_members_of() |
Get struct fields |
std::meta::identifier_of() |
Get field name |
std::define_static_array() |
Convert to constexpr array |
template for |
Expansion statement |
- Requires
-freflectionflag nonstatic_data_members_of()needsaccess_context::current()parameter- Use
std::define_static_array()to make ranges constexpr-compatible