c++-modules

how to use standard library with C++ modules? (eg: `import std.io`)

对着背影说爱祢 提交于 2019-12-22 06:06:13
问题 The basic example given in How do I use C++ modules in Clang? works for me but doesn't import the standard library (eg via import std.stdio; ); after going over http://clang.llvm.org/docs/Modules.html it wasn't clear how to use the standard library in a C++ module, eg: // foo.cppm: export module foo; // works: #include <stdio.h> // none of these work: import std.stdio; import std.io; import std; export void test_foo(){ printf("hello world\n"); } this gives an error: clang++ -std=c++17

Clang++ -fmodules errors using types after #include <cstdint>

萝らか妹 提交于 2019-12-13 13:16:49
问题 The following simple test case file is giving me a compile-time error with the tip of 'master' from Clang's github mirror, when compiled with -fmodules , using the command shown below. I'm wondering if this is a bug with the new experimental Module feature for Clang -- maybe a problem with the implementation of module maps for the standard library -- or if there's something I'm doing wrong. The error still appears if I add -fbuiltin-module-map to the command. Interestingly, the error no

Linking C++ modules TS using clang

筅森魡賤 提交于 2019-12-01 14:34:31
I'm trying to use C++ modules TS with clang. I've created two files: // foo.cppm export module foo; export void test() { } and // bar.cpp import foo; int main() { test(); return 0; } I compile foo.cppm with this command clang++ --std=c++17 -fmodules-ts --precompile foo.cppm -o foo.pcm It compiles without an error and creates a foo.pcm file, but when i try to compile a binary with this command: clang++ --std=c++17 -fmodules-ts -fprebuilt-module-path=. -fmodule-file=foo.pcm bar.cpp it prints an error: /tmp/bar-f69a1f.o: In function `main': bar.cpp:(.text+0x10): undefined reference to `test()' I

How should I write my C++ to be prepared for C++ modules?

旧街凉风 提交于 2019-11-29 21:14:31
There are already two compilers that support C++ modules: Clang: http://clang.llvm.org/docs/Modules.html MS VS 2015: http://blogs.msdn.com/b/vcblog/archive/2015/12/03/c-modules-in-vs-2015-update-1.aspx When starting a new project now, what should I pay attention to in order to be able to adopt the modules feature when it is eventually released in my compiler? Is it possible to use modules and still maintain compatibility with older compilers that do not support it? There are already two compilers that support C++ modules clang: http://clang.llvm.org/docs/Modules.html MS VS 2015: http://blogs

How should I write my C++ to be prepared for C++ modules?

余生颓废 提交于 2019-11-28 17:19:59
问题 There are already two compilers that support C++ modules: Clang: http://clang.llvm.org/docs/Modules.html MS VS 2015: http://blogs.msdn.com/b/vcblog/archive/2015/12/03/c-modules-in-vs-2015-update-1.aspx When starting a new project now, what should I pay attention to in order to be able to adopt the modules feature when it is eventually released in my compiler? Is it possible to use modules and still maintain compatibility with older compilers that do not support it? 回答1: There are already two

How do I use C++ modules in Clang?

牧云@^-^@ 提交于 2019-11-28 06:46:50
Modules are an alternative to #includes. Clang has a complete implementation for C++ . How would I go about if I wanted to use modules using Clang now? Using import std.io; in a C++ source file does not work (compile) yet, as the specification for modules (which includes syntax) isn't final. The Clang documentation states that, when passing the -fmodules flag, #includes will be rewritten to their appropriate imports. However, checking the preprocessor suggests otherwise (test.cpp only contains #include <stdio.h> and an empty main): $ clang++-3.5 -fmodules -E test.cpp -o test $ grep " printf "

How do I use C++ modules in Clang?

淺唱寂寞╮ 提交于 2019-11-27 01:35:42
问题 Modules are an alternative to #includes. Clang has a complete implementation for C++. How would I go about if I wanted to use modules using Clang now? Using import std.io; in a C++ source file does not work (compile) yet, as the specification for modules (which includes syntax) isn't final. The Clang documentation states that, when passing the -fmodules flag, #includes will be rewritten to their appropriate imports. However, checking the preprocessor suggests otherwise (test.cpp only contains