Skip to content

feat: Add C++ modules support and update nlohmann::json#1530

Open
mikomikotaishi wants to merge 3 commits intobrainboxdotcc:devfrom
mikomikotaishi:dev
Open

feat: Add C++ modules support and update nlohmann::json#1530
mikomikotaishi wants to merge 3 commits intobrainboxdotcc:devfrom
mikomikotaishi:dev

Conversation

@mikomikotaishi
Copy link
Contributor

This pull request adds support for C++20 modules.

In order to accomplish this, some constants were changed to using external linkage. I have also updated nlohmann/json to version 3.12.0, as the older version declares some symbols as internal.

Code change checklist

  • I have ensured that all methods and functions are fully documented using doxygen style comments.
  • My code follows the coding style guide.
  • I tested that my change works before raising the PR.
  • I have ensured that I did not break any existing API calls.
  • I have not built my pull request using AI, a static analysis tool or similar without any human oversight.

@netlify
Copy link

netlify bot commented Dec 27, 2025

Deploy Preview for dpp-dev ready!

Name Link
🔨 Latest commit bda0199
🔍 Latest deploy log https://app.netlify.com/projects/dpp-dev/deploys/696a14721735df00087a19ff
😎 Deploy Preview https://deploy-preview-1530--dpp-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added documentation Improvements or additions to documentation build Issue or Pull Request related to the build process code Improvements or additions to code. labels Dec 27, 2025
@Jaskowicz1 Jaskowicz1 added the enhancement New feature or request label Dec 27, 2025
@mikomikotaishi mikomikotaishi force-pushed the dev branch 3 times, most recently from e91eaa8 to 121eb9b Compare December 27, 2025 12:04
Copy link
Member

@Mishura4 Mishura4 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Good stuff. Just gonna prefer the approach with including dpp.h in the module for maintainability, as discussed in https://discord.com/channels/825407338755653642/825411104208977952/1454456223952011427

Copy link
Contributor

@braindigitalis braindigitalis left a comment

Choose a reason for hiding this comment

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

some module related unit tests would be good. not repeating a thousand lines of code in dpp.cppm is an absolute must, as @Mishura4 also said.

@mikomikotaishi
Copy link
Contributor Author

mikomikotaishi commented Dec 27, 2025

I've looked at the src/unittest/ files but I'm not particularly familiar with how you've set up the unit testing framework. Are you just looking to run those same tests under import dpp; rather than #include <dpp/dpp.h>?

@braindigitalis
Copy link
Contributor

I think that in this case you might want to make a new .cpp under the unittests folder which imports dpp instead of #including it. it can have some test functions that are exported and called via standard approaches from the main unittest file.

@mikomikotaishi mikomikotaishi force-pushed the dev branch 3 times, most recently from 1909f3f to 7f6fb23 Compare December 28, 2025 06:06
@mikomikotaishi
Copy link
Contributor Author

I think this should fix the errors we're encountering. It's with the build system configuration

@braindigitalis
Copy link
Contributor

you cant just do -DDPP_MODULES=ON for the entire CI matrix. Some CI's use older g++ (which we support) and some use C++17.

@mikomikotaishi
Copy link
Contributor Author

Then is it possible to disable the modules unit tests for C++17 CI tests?

@mikomikotaishi
Copy link
Contributor Author

@braindigitalis I think the modules CI should just be in a totally separate CI. It requires Ninja, as CMake can't build modules with Makefiles.

@braindigitalis
Copy link
Contributor

unit tests only run in one g++, which is g++-12. This is the one which is packaged. we cant and dont run unit tests on them all, as the unit tests connect to discord and we cant do this concurrently.

@Jaskowicz1 Jaskowicz1 changed the title Add C++ modules support and update nlohmann::json feat: Add C++ modules support and update nlohmann::json Dec 29, 2025
@Jaskowicz1
Copy link
Contributor

Updated Title to match code standards

@mikomikotaishi
Copy link
Contributor Author

mikomikotaishi commented Dec 31, 2025

Hmm, this problem with the standard library has to do with symbols having internal linkage. They fixed most of this in GCC 15, because that's when they shipped module std.

Let me try it with Ubuntu 25.10 and GCC 15

@mikomikotaishi mikomikotaishi force-pushed the dev branch 2 times, most recently from 9d0c210 to cc1e8db Compare December 31, 2025 06:01
@Jaskowicz1
Copy link
Contributor

Jaskowicz1 commented Dec 31, 2025

Since you're having issues with g++-14 (which makes no sense because I can build g++-14 modules fine locally), just use a clang version that's supported (pretty sure clang15 has modules, but use clang18).

Make sure you set the CXX for the env on both builds and then the apt install too 🫡

@mikomikotaishi
Copy link
Contributor Author

I have no idea why this current error is happening seeing as it never happened on my end, though I built mine in Clang 21.

@Jaskowicz1
Copy link
Contributor

Seems it's a clang18 issue 🙃 , change to clang20

@mikomikotaishi mikomikotaishi force-pushed the dev branch 10 times, most recently from b3a12cd to c241af2 Compare January 15, 2026 06:32
endif()
if(BUILD_SHARED_LIBS)
if (DPP_MODULES)
target_link_libraries(${testname} PUBLIC dpp_module)
Copy link
Member

Choose a reason for hiding this comment

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

Can't we set it up so that target_link_libraries(${testname} PUBLIC dpp) brings the module, as discussed on the discord?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think my current revision fixes this, but please review and let me know if it is acceptable.

@Jaskowicz1
Copy link
Contributor

Im rather confused why the CI keeps saying

Manually-specified variables were not used by the project:

    DPP_MODULES

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issue or Pull Request related to the build process code Improvements or additions to code. documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants