|
1 | 1 | # learnmoderncpp-tutorial
|
2 | 2 |
|
3 |
| -Complete, working programs from the C++ tutorial hosted at https://learnmoderncpp.com/course-details/ |
| 3 | +Complete, working programs from the C++ tutorial hosted at: |
| 4 | + |
| 5 | +https://learnmoderncpp.com/course-details/ |
4 | 6 |
|
5 | 7 | ## Usage
|
6 | 8 |
|
7 |
| -The "headers" directory contains C++ programs with legacy header `#includes`, |
8 |
| -whilst the "modules" directory contains the same programs but using the `import` keyword instead. |
| 9 | +The "headers" subdirectory contains C++ programs with legacy header `#includes`, whilst the "modules" subdirectory contains the same programs but using the `import` keyword instead. See https://learnmoderncpp.com/2020/09/05/where-are-c-modules/ for more details about C++ compilers which have support for modules. |
| 10 | + |
| 11 | +## Compiling under Windows |
9 | 12 |
|
10 | 13 | All programs compile successfully under Windows with Visual Studio 2019 (v16.8 or later).
|
11 | 14 |
|
12 | 15 | The supplied batch scripts `build-vs2019-headers.bat` and
|
13 |
| -`build-vs2019-modules.bat` can be used to compile all of the programs within a Visual Studio command prompt terminal; simply run: |
14 |
| -"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat" |
15 |
| -or similar in a command window, or create a desktop link. |
| 16 | +`build-vs2019-modules.bat` can be used to compile all of the programs within a Visual Studio command prompt, simply run: |
| 17 | + |
| 18 | +```C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat``` |
| 19 | + |
| 20 | +or similar in a command window, or create a desktop link, and then run either of the build scripts. |
| 21 | + |
| 22 | +Alternatively, to compile individual programs from within a Visual Studio command prompt run either (modules): |
| 23 | + |
| 24 | +``` |
| 25 | +cl /EHsc /std:c++latest /experimental:moodule /MD 00-example.cpp |
| 26 | +``` |
16 | 27 |
|
17 |
| -To compile individual programs under Linux, use: |
| 28 | +or (headers): |
18 | 29 |
|
19 | 30 | ```
|
20 |
| -g++ -std=c++20 -o prog prog.cpp # (for the headers versions) |
| 31 | +cl /EHsc /std:c++latest 00-example.cpp |
21 | 32 | ```
|
22 | 33 |
|
23 |
| -or |
| 34 | +substituting the correct file for `00-example.cpp` in either case. |
| 35 | + |
| 36 | +## Compiling under Linux |
| 37 | + |
| 38 | +To compile individual programs in the "headers" subdirectory under Linux, use: |
| 39 | + |
24 | 40 | ```
|
25 |
| -clang++ -std=c++20 -o prog prog.cpp # (again for the headers versions) |
| 41 | +g++ -std=c++20 -o 00-example 00-example.cpp |
26 | 42 | ```
|
27 | 43 |
|
28 |
| -Alternatively, run the supplied shell scripts which are supplied in both the "headers" and "modules" subdirectories. |
| 44 | +or: |
| 45 | + |
| 46 | +``` |
| 47 | +clang++ -std=c++20 -o 00-example 00-example.cpp |
| 48 | +``` |
29 | 49 |
|
30 |
| -**Contact:** cpptutor@outlook.com |
| 50 | +substituting both occurrencies of `00-example` with the correct file name. |
31 | 51 |
|
| 52 | +Alternatively, run one of the supplied shell scripts `build-gcc-headers.sh` or `build-clang-headers.sh` which are supplied in the "headers" subdirectory, or `build-clang-modules.sh` found in the "modules" subdirectory. (The last of these needs to change `import std.core;` to `import std;` for each source file before compilation, using the `sed` utility.) |
0 commit comments