What about a macro to define enums?
@PhilipFackler is already working on this.
Since Jun 12, 2026.
- Dominant language
- C++
- Stars
- 27
- Forks
- 11
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 23
Description
Comments on #440 got me thinking about this (again), especially because we don't want magic_enum to creep into the core code. So I gave it a shot.
Attached is an implementation of a preprocessor macro (most of which I copied from a blog) and some examples. This implements parse, print, and size functions. There's more we could do if everyone is in-favor of the basic approach, but also I would completely understand any resistance. I dislike macros generally, but in this case it seems a good workaround to the limitations on enums in C++.
Also, try it out here.
https://godbolt.org/z/KvvTT3hv1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.