ORNL / ORNL/GridKit

What about a macro to define enums?

Open
#450 2 comments 0 reactions 5 assignees View on GitHub

@PhilipFackler is already working on this.

Since Jun 12, 2026.

question
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++.

enum_prop.cpp

Also, try it out here.
https://godbolt.org/z/KvvTT3hv1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.