Skip to content

Add C++20 modules support and format btw.#669

Open
Perdixky wants to merge 2 commits into
getml:mainfrom
Perdixky:main
Open

Add C++20 modules support and format btw.#669
Perdixky wants to merge 2 commits into
getml:mainfrom
Perdixky:main

Conversation

@Perdixky
Copy link
Copy Markdown

As the library depends on C++20, I think the support for modules is definitely important 😊
So I’ve added this.
If this change is approved, I’ll add the corresponding documentation later.
By the way, should we convert all the test files to use modules? This would prevent errors caused by missing exported entities, but it might be a bit aggressive.

Perdixky and others added 2 commits May 17, 2026 22:42
Add an opt-in REFLECTCPP_BUILD_MODULES path that registers CMake CXX_MODULES file sets for rfl, generic, cli, JSON, and each optional serialization format when its existing feature option is enabled.

The module interfaces include the existing public headers in the global module fragment, then explicitly re-export reflect-cpp public names with using declarations. That keeps the include headers as the source of truth while avoiding attaching standard-library and C headers directly to named modules.

Change namespace-scope public constants and module-visible helpers from internal-linkage static objects/functions to inline constexpr/inline forms. Exported templates can otherwise refer to entities owned by one module interface translation unit, which makes the imported API depend on unstable TU-local addresses and can diverge from include mode.

Signed-off-by: Perdixky <3293789706@qq.com>

Co-authored-by: Codex <codex@openai.com>
Apply clang-format to include/rfl/cli/Reader.hpp only.

Signed-off-by: Perdixky <3293789706@qq.com>

Co-authored-by: Codex <codex@openai.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces experimental support for C++20 modules, adding module interface files and updating the CMake build system to support module compilation and installation. It also refactors internal headers to use inline and constexpr for improved linkage. Feedback highlights that changes to the third-party yyjson.h header break C compatibility by using C++-specific keywords; these macros should be guarded with preprocessor checks to maintain support for C users.

Comment thread include/rfl/thirdparty/yyjson.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant