-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,36 @@ | ||
# Running C++20 Code with GCC | ||
|
||
This guide outlines the steps to compile and run C++20 code using the GNU Compiler Collection (GCC). It is intended for those who want to work with modern C++ features. More specifcially, it is important that we use a consistent version of C++ throughout the entirety of this project to ensure consistency. | ||
|
||
Flag | ||
```bash | ||
-std=c++20 | ||
``` | ||
should be used on all g++ compilation commands. | ||
|
||
## Prerequisites | ||
Before running C++20 code, ensure you have the following: | ||
- GCC installed (Version 10 or later for C++20 support) | ||
- Basic understanding of C++ programming | ||
- A terminal or command-line environment | ||
|
||
## Compiling C++20 Code | ||
To compile a C++20 program, use the following command in your terminal or command line: | ||
|
||
```bash | ||
g++ -std=c++20 <source-file> -o <output-file> | ||
``` | ||
|
||
## Example | ||
Here's an example to compile a C++20 program, main.cpp, into an executable called my_program: | ||
|
||
```bash | ||
g++ -std=c++20 main.cpp -o my_program | ||
``` | ||
|
||
## Running the program | ||
To run the compiled executable, use the following command: | ||
```bash | ||
./my_program | ||
``` | ||
This will execute the compiled code and display the output in your terminal or command-line environment. |
Binary file not shown.
This file contains 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,13 @@ | ||
#include <iostream> | ||
#include <ranges> | ||
|
||
// test program to ensure successfull c++ 20 setup and gcc setup | ||
int main() | ||
{ | ||
std::vector<int> numbers = {1, 2, 3, 4, 5}; | ||
for (int i = 0; i < numbers.size(); i++) | ||
{ | ||
std::cout << numbers[i] << " "; | ||
} | ||
return 0; | ||
} |