Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
howto:modules_gcc11 [2021-02-01 19:13] rrichter angelegt |
howto:modules_gcc11 [2021-02-01 19:44] (aktuell) rrichter [Compile program] |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== How to use C++0 modules in GNU g++-11 ====== | + | ====== How to use C++20 modules in GNU g++-11 ====== |
- | using gcc11-20210124-32.exe (Windows build on http:%%//%%www.equation.com/ | + | using gcc11-20210124-32.exe (Windows build from [[http:// |
===== module definition ===== | ===== module definition ===== | ||
Zeile 12: | Zeile 12: | ||
// ... | // ... | ||
</ | </ | ||
- | before '' | + | before '' |
- | <code cpp> | + | < |
export module greetings; | export module greetings; | ||
import < | import < | ||
Zeile 25: | Zeile 25: | ||
===== module interface unit ===== | ===== module interface unit ===== | ||
- | Every module consists of exactly one module interface unit '' | + | Every module consists of exactly one module interface unit '' |
===== import module ===== | ===== import module ===== | ||
Zeile 31: | Zeile 31: | ||
by its module name if you want to use the contents of a module | by its module name if you want to use the contents of a module | ||
- | <code cpp> | + | < |
import greetings; | import greetings; | ||
Zeile 39: | Zeile 39: | ||
} | } | ||
</ | </ | ||
- | ===== Prepare std header unit(s) ===== | + | ===== Prepare |
- | before compiling modularized source code containing e.g. '' | + | before compiling modularized source code containing e.g. '' |
< | < | ||
- | g++ -fmodule-header | + | g++ -fmodules-ts -std=c++20 |
</ | </ | ||
- | (adapt the path to include | + | Other options are '' |
===== Compile program ===== | ===== Compile program ===== | ||
- | with option '' | + | with option '' |
< | < | ||
Zeile 61: | Zeile 60: | ||
Hello, modules! | Hello, modules! | ||
</ | </ | ||
+ | |||
+ | ===== Further reading ===== | ||
+ | * Nathan Sidwell: C++ Modules. A Brief Tour. Overload 28(159) 19-23, October 2020. https:// | ||
+ | |||