Skip to content

Support for C++20/23 modules#395

Draft
DockedFerret800 wants to merge 6 commits intoThalhammer:masterfrom
DockedFerret800:modules
Draft

Support for C++20/23 modules#395
DockedFerret800 wants to merge 6 commits intoThalhammer:masterfrom
DockedFerret800:modules

Conversation

@DockedFerret800
Copy link
Copy Markdown

@DockedFerret800 DockedFerret800 commented Sep 25, 2025

This adds support for C++20/23 modules. Please let me know if you want anything done in a different way. There is still some work left to do: update all examples, tests, docs and CI/CD. I tested the code on Windows, with MSVC latest (v18) on a print-claims example.

JWT_ENABLE_MODULES - to enable modules
JWT_USE_IMPORT_STD - to use import std

UPD: The latest implementation was tested with MSVC (14.51) 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
Copy link
Copy Markdown
Author

DockedFerret800 commented Jan 3, 2026

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
Copy link
Copy Markdown
Author

DockedFerret800 commented Mar 14, 2026 via email

@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.

Copy link
Copy Markdown

@ChuanqiXu9 ChuanqiXu9 left a comment

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
#include <openssl/ssl.h>

#ifdef JWT_USE_IMPORT_STD
import std;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As we have import std; in jwt.ixx. I think we don't need this, do we?

Comment thread modules/jwt.ixx
@@ -0,0 +1,85 @@
module;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: I prefer jwt.cppm

Comment thread modules/jwt.ixx
// Build the public headers in module purview so imported declarations are
// attached to jwt_cpp instead of the global module.
#define JWT_CPP_MODULE_INTERFACE_BUILD 1
export {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: export all seems slightly not good but it is your choices.

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