Skip to content

Support for C++20/23 modules#395

Open
DockedFerret800 wants to merge 15 commits into
Thalhammer:masterfrom
DockedFerret800:modules
Open

Support for C++20/23 modules#395
DockedFerret800 wants to merge 15 commits into
Thalhammer:masterfrom
DockedFerret800:modules

Conversation

@DockedFerret800

@DockedFerret800 DockedFerret800 commented Sep 25, 2025

Copy link
Copy Markdown

This adds support for C++20/23 modules.

JWT_ENABLE_MODULES - to enable modules

Modules are tested in CI with MSVC 14.51, Clang-22 and GCC-15.

UPD: The latest implementation was tested with MSVC (14.51 and 14.52) and Clang-22

Comment thread CMakeLists.txt
@DockedFerret800

Copy link
Copy Markdown
Author

I didn't manage to get import std working properly yet. I'll continue over the weekend.

@DockedFerret800

DockedFerret800 commented Jan 3, 2026

Copy link
Copy Markdown
Author

I'm having trouble pairing modules and tests with GTest, primarily related to this issue: google/googletest#4851. I'll see what I can do tomorrow.

All examples appear to work

@ChuanqiXu9

Copy link
Copy Markdown

Hi I am looking forward to using this. What's the problem you are seeing? if it is the import-#include ordering thing, can we just have #include before import in the tests? And it is not so strict, see: https://github.com/alibaba/async_simple/blob/CXX20Modules/async_simple_module/test/coro/SleepTest.cpp

@DockedFerret800

DockedFerret800 commented Mar 14, 2026 via email

Copy link
Copy Markdown
Author

@DockedFerret800

Copy link
Copy Markdown
Author

@ChuanqiXu9 Hi. Sorry for the delay. I’ve just pushed a commit that now uses ABI-breaking wrapper style. Could you have a look at the current implementation and tell whether you're satisfied with it? Thank you.

@ChuanqiXu9 ChuanqiXu9 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The patch LGTM with some nits. Feel free to ignore them.

Comment thread include/jwt-cpp/jwt.h Outdated
Comment thread modules/jwt.cppm
Comment thread modules/jwt.cppm Outdated
@DockedFerret800

Copy link
Copy Markdown
Author

@prince-chrismc Thank you for resolving conflicts. I'll add a workflow for modules tomorrow and do some minor cleanups, so I think this will be ready soon. Sorry for the delay.

@prince-chrismc prince-chrismc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Few small questions

Comment thread include/picojson/picojson.h Outdated
#ifndef picojson_h
#define picojson_h

#if defined(JWT_CPP_MODULE_INTERFACE_BUILD) && defined(JWT_USE_IMPORT_STD)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Picojson is a vendored dep, we shouldn't be making changes to it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This doesn't make any behavioural changes, just exports necessary interfaces. I'm not sure how to implement support for modules without modifying it.

Comment thread CMakeLists.txt Outdated
target_compile_features(jwt-cpp ${JWT_LIBRARY_TYPE} cxx_std_20)
else()
target_compile_features(jwt-cpp ${JWT_LIBRARY_TYPE} cxx_std_23)
target_compile_definitions(jwt-cpp PRIVATE JWT_USE_IMPORT_STD)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If this was public, could we remove the extra defines in the examples and test apps?

Comment thread example/traits/boost-json.cpp Outdated
Comment thread CMakeLists.txt Outdated
Comment thread CMakeLists.txt Outdated
@DockedFerret800

Copy link
Copy Markdown
Author

Just wanted to give an update. I'm currently waiting for the Ubuntu 26 image to be available in GitHub Actions, so I can setup a CI to test modules.

@DockedFerret800 DockedFerret800 marked this pull request as ready for review June 13, 2026 13:42
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.

4 participants