-
-
Notifications
You must be signed in to change notification settings - Fork 208
feat: Add C++ modules support #1530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mikomikotaishi
wants to merge
26
commits into
brainboxdotcc:dev
Choose a base branch
from
mikomikotaishi:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
cc86cef
Add C++ modules support and update nlohmann::json
mikomikotaishi b9e4215
Move module to include/ directory, add compiling example program for …
mikomikotaishi 868782b
Add modules unit test
mikomikotaishi 1d41aa9
Trying specific handling for CMake examples
mikomikotaishi ce88aff
Manually link the module instead of relying on CMake for now
mikomikotaishi 7defeb8
Merge branch 'dev' into dev
mikomikotaishi 15dbf83
Merge branch 'dev' into dev
mikomikotaishi 6c828af
Merge branch 'dev' into dev
mikomikotaishi 349c958
Remove now irrelevant attributes
mikomikotaishi 2eb60f1
Remove edits to json.hpp
mikomikotaishi 6d39166
Merge branch 'dev' into dev
mikomikotaishi 531227d
Restore removed `-rdynamic` flag
mikomikotaishi d887c03
Add a static-linux and install-consumer job on CI
mikomikotaishi 8cf7f90
Merge branch 'dev' into dev
mikomikotaishi 55eadfb
Merge branch 'dev' into dev
mikomikotaishi d87cb46
Merge branch 'dev' into dev
braindigitalis b1699de
Merge branch 'dev' into dev
mikomikotaishi ac09477
Apply recommended docs changes
mikomikotaishi 4a12d0c
Add a CI for building the module on Windows
mikomikotaishi 37a91e0
Merge branch 'dev' into dev
mikomikotaishi 81fdff6
Merge branch 'dev' into dev
mikomikotaishi 294146b
Fix reported issues by maintainers
mikomikotaishi 7e8b739
Explicitly disable GNU extensions
mikomikotaishi 54bcd73
Use ClangCL instead of cl.exe, due to error C2039
mikomikotaishi fd95cb5
Clarify CMake instructions for modules
mikomikotaishi 4f33bf2
Merge branch 'dev' into dev
Jaskowicz1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #include <string> | ||
|
|
||
| import dpp; | ||
|
|
||
| int main() { | ||
| dpp::cluster bot("YOUR_BOT_TOKEN_HERE"); | ||
|
|
||
| bot.on_slashcommand([](const dpp::slashcommand_t& event) -> void { | ||
| if (event.command.get_command_name() == "ping") { | ||
| event.reply("Pong!"); | ||
| } | ||
| }); | ||
|
|
||
| bot.on_ready([&bot](const dpp::ready_t& event) -> void { | ||
| if (dpp::run_once<struct register_bot_commands>()) { | ||
| bot.global_command_create( | ||
| dpp::slashcommand("ping", "Ping pong!", bot.me.id) | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| bot.start(dpp::start_type::st_wait); | ||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| \page using_modules Using D++ with C++ modules | ||
|
|
||
|
Jaskowicz1 marked this conversation as resolved.
|
||
| \include{doc} modules_warn.dox | ||
|
|
||
| D++ is offered as a C++ module, which offers improved compile times over a traditional header. | ||
|
|
||
| In order to enable support, you must use C++20 (or later) with any module-supporting compiler. To activate the feature, pass the `DPP_MODULES` flag to CMake. Ensure that the generated build system supports modules (for CMake, this is usually Ninja; note CMake does not currently support modules with Makefile). | ||
|
|
||
| Once this is done, simply `import dpp;` and we're good to go! | ||
|
|
||
| \include{cpp} using_modules.cpp | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| \warning D++ modules are currently experimental and are only supported by D++ on g++ 15, clang/LLVM 17, and MSVC 17.6 or above. Additionally, your program has to support C++20. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /************************************************************************************ | ||
| * | ||
| * D++, A Lightweight C++ library for Discord | ||
| * | ||
| * Copyright 2021 Craig Edwards and D++ contributors | ||
| * (https://github.com/brainboxdotcc/DPP/graphs/contributors) | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| ************************************************************************************/ | ||
|
|
||
| module; | ||
|
|
||
| // Include the entire standard library so it doesn't cause issue in our headers | ||
| #include <cstddef> | ||
| #include <cstdint> | ||
| #include <cstring> | ||
| #include <ctime> | ||
|
|
||
| #include <algorithm> | ||
| #include <charconv> | ||
| #include <condition_variable> | ||
| #include <cstddef> | ||
| #include <ctime> | ||
| #include <deque> | ||
| #include <exception> | ||
| #include <fstream> | ||
| #include <functional> | ||
| #include <iomanip> | ||
| #include <iostream> | ||
| #include <locale> | ||
| #include <map> | ||
| #include <memory> | ||
| #include <mutex> | ||
| #include <optional> | ||
| #include <queue> | ||
| #include <shared_mutex> | ||
| #include <sstream> | ||
| #include <string> | ||
| #include <string_view> | ||
| #include <thread> | ||
| #include <type_traits> | ||
| #include <unordered_map> | ||
| #include <variant> | ||
| #include <vector> | ||
|
|
||
| #include <dpp/export.h> | ||
| #include <dpp/compat.h> | ||
|
|
||
| #ifdef DPP_USE_EXTERNAL_JSON | ||
| #include <nlohmann/json.hpp> | ||
| #else | ||
| #include <dpp/nlohmann/json.hpp> | ||
| #endif | ||
|
|
||
| export module dpp; | ||
|
|
||
| export extern "C++" { | ||
| #if defined(__clang__) | ||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wunknown-warning-option" | ||
| #pragma clang diagnostic ignored "-Winclude-angled-in-module-purview" | ||
| #endif | ||
|
|
||
| #include <dpp/dpp.h> | ||
| #include <dpp/dns.h> | ||
| #include <dpp/restrequest.h> | ||
| #include <dpp/unicode_emoji.h> | ||
|
Mishura4 marked this conversation as resolved.
|
||
|
|
||
| #if defined(__clang__) | ||
| #pragma clang diagnostic pop | ||
| #endif | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.