c++-modules

Standard way of importing modules

安稳与你 提交于 2021-01-03 03:22:15
问题 I am currently trying to use c++ modules in a code that should compile both on Windows (MSVC) and Linux (Clang and/or GCC). I am currently developping in Visual Studio and used the "Standard Conformance Mode" (/permissive-) to make my code as portable as possible. However the following code: import std.core; int main() { std::cout << "Hello, World! haha" << std::endl; std::vector<int> myVec{4}; std::map<std::string, size_t> myMap; return 0; } Can not compile with the /permissive- flag. I get

Standard way of importing modules

≡放荡痞女 提交于 2021-01-03 03:14:00
问题 I am currently trying to use c++ modules in a code that should compile both on Windows (MSVC) and Linux (Clang and/or GCC). I am currently developping in Visual Studio and used the "Standard Conformance Mode" (/permissive-) to make my code as portable as possible. However the following code: import std.core; int main() { std::cout << "Hello, World! haha" << std::endl; std::vector<int> myVec{4}; std::map<std::string, size_t> myMap; return 0; } Can not compile with the /permissive- flag. I get

Standard way of importing modules

ε祈祈猫儿з 提交于 2021-01-03 03:13:21
问题 I am currently trying to use c++ modules in a code that should compile both on Windows (MSVC) and Linux (Clang and/or GCC). I am currently developping in Visual Studio and used the "Standard Conformance Mode" (/permissive-) to make my code as portable as possible. However the following code: import std.core; int main() { std::cout << "Hello, World! haha" << std::endl; std::vector<int> myVec{4}; std::map<std::string, size_t> myMap; return 0; } Can not compile with the /permissive- flag. I get

How to use c++20 modules with CMake?

我怕爱的太早我们不能终老 提交于 2020-12-25 01:41:40
问题 Clang and MSVC already supports Modules TS from unfinished C++20 standard. Can I build my modules based project with CMake or other build system and how? I tried build2, it supports modules and it works very well, but i have a question about it's dependency management (UPD: question is closed). 回答1: This works on Linux Manjaro (same as Arch), but should work on any Unix OS. Of course, you need to build with new clang (tested with clang-10). helloworld.cpp: export module helloworld; import

How to use c++20 modules with CMake?

≯℡__Kan透↙ 提交于 2020-12-25 01:41:17
问题 Clang and MSVC already supports Modules TS from unfinished C++20 standard. Can I build my modules based project with CMake or other build system and how? I tried build2, it supports modules and it works very well, but i have a question about it's dependency management (UPD: question is closed). 回答1: This works on Linux Manjaro (same as Arch), but should work on any Unix OS. Of course, you need to build with new clang (tested with clang-10). helloworld.cpp: export module helloworld; import

How to include multiple precompiled headers in with c++20 (with modules enabled) in gcc or clang

China☆狼群 提交于 2020-12-12 05:39:51
问题 In c++20, when enabling modules, each include is supposed to be encapsulated so that the ordering does not matter, and macros does not leak out etc. Apparently the question if it is possible to precompile multiple headers is yes. My question now is: How do you do this: That is: How do i first precompile a set of headers and then make the compiler recognize them (all of them) as precompiled headers for my translation unit using c++20 modules, (using linux command line). I would like to have

Forward declarations in C++ modules (MSVC)

独自空忆成欢 提交于 2020-08-22 15:12:22
问题 I have been experimenting with modules implementation as provided by the MSVC lately and I've run into an interesting scenario. I have two classes that have a mutual dependency in their interfaces, which means that I'll have to use forward declarations to get it to compile. The following code shows an example: Module interface export module FooBar; export namespace FooBar { class Bar; class Foo { public: Bar createBar(); }; class Bar { public: Foo createFoo(); }; } Module implementation

How are templates handled in C++ module system?

北慕城南 提交于 2020-06-09 11:09:37
问题 I am reading the paper A Module System for C++ to understand C++ modules, a proposed feature for C++. I am not able to fully understand how templates will be exported by this module architecture. Any ideas? 回答1: Currently C++ implementations really only have two "things" that correspond to code: source code that we human write and edit, and assembly, which the compiler spits out based on source. Because C++ templates are "reified", separate assembly is spit out for each template instantiation

How are templates handled in C++ module system?

爷,独闯天下 提交于 2020-06-09 11:07:12
问题 I am reading the paper A Module System for C++ to understand C++ modules, a proposed feature for C++. I am not able to fully understand how templates will be exported by this module architecture. Any ideas? 回答1: Currently C++ implementations really only have two "things" that correspond to code: source code that we human write and edit, and assembly, which the compiler spits out based on source. Because C++ templates are "reified", separate assembly is spit out for each template instantiation

How to use template explicit instantiation with C++20 modules?

◇◆丶佛笑我妖孽 提交于 2020-05-13 12:07:51
问题 As explained in this answer template instantiation allows reducing compilation times and sizes by not requiring templates to be recompiled for every new type in every new file that uses them. I'm also excited about how C++20 modules should provide a clean solution to expose templates to external projects and reduce hpp/cpp duplication. What is the syntax that will allow them to work together? For example, I expect modules to look a bit like (untested and therefore likely wrong code because I