Add C++20 modules support and format btw.#669
Conversation
There was a problem hiding this comment.
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.
|
Hi @Perdixky , thanks for your contribution. To be honest, we have tried adding module support a while ago and back then there were so many problems that we decided modules are not yet ready for prime time. But I'd be happy to give them another try. |
|
@Perdixky , could you also add the module tests that you have written to the automated Github Actions testing pipeline? It does not appear that your tests are actually compiled or executed. |
|
@Perdixky, are you planning to continue working on this? Otherwise I will have to close this due to inactivity? |
@liuzicheng1987 , I'm a bit busy at this moment, but I'll follow up on this work! Please bear with me for a few weeks! |
|
@Perdixky no problem! |
|
Hi @liuzicheng1987! There are a few issues I need to report:
module;
#include "rfl/cli.hpp"
export module rfl.cli;
export import rfl;
export namespace rfl::cli {
using ::rfl::cli::read;
}
namespace std {
template <int I, class... Types>
constexpr auto& get(rfl::Tuple<Types...>&);
}which is undefined behavior and cannot be exported by modules. I'll make a manifest later so that you can decide how to handle them. |
Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Claude Code <noreply@anthropic.com>
|
@Perdixky you should merge main into your feature branch. Some of these issues might already be resolved. |
|
@liuzicheng1987 These commits have already been shipped. Please feel free to review them and let me know if you have any feedback! |
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.