Background
Like most other programming languages, C++ comes in many versions. Newer versions bring improvements as well as remove or add new features to the language. C++ has the following standard versions:
- C++98 is the first edition (1998).
- C++03 is the second edition (2003).
- C++11 is the third edition (2011).
- C++14 is the fourth edition (2014).
- C++17 is the fifth edition (2017).
Currently, C++ Standards Committee is responsible for C++ releases and has currently fixed a three-year release cycle. As of 2019, the next version (C++20) is currently under preparations.
Important: Please confirm the C++ version that will be used for your NECTA practical exams ahead of time.
C++17 added inbuilt support for filesystem operations (listing folder contents, traversing folders, moving files, etc.). For this reason, C++17 will be required to complete 2019 Projects.
Installing CodeBlocks
You can install CodeBlocks in Ubuntu by running the following command in the Terminal:
$ sudo apt update && sudo apt install codeblocks g++
Configuring CodeBlocks for C++ 2017
We need to update the compiler and linker flags to instruct them to compile the source files as C++ 2017 source code and include the filesystem
header when linking.
To accomplish this, go to Settings
in the menu and select Compiler...
Ensure the Global compiler settings
section on the left is selected. Then, select the Compiler Flags
tab. This section should look similar to the image below.
Notice that at the time of writing, there is an inbuilt support for C++11 and C++14 versions, as it can be seen in the image above.
Right-click inside the General
area and select New flag...
.
Add details as shown in the image below. Name
can be anything.
Add -std=c++17
in the Compiler flags
.
Add -lstdc++fs
in the Linker flags
.
Select General
for the Category
.
Select False
for the Exclusive
.
Other sections should be left blank. Click OK
to save.
Ensure the new row we have just added is checked as shown below. Click OK
to save and exit.
Now you can compile C++ source code following the C++ 2017 standard.