KDE neon 5.23, Code::Blocks 20.03 rev 11997, gcc 11.2.0. I installed Code::Blocks from Flathub
So, I'm trying to learn C++. The tutorial I'm using to learn it recommends using C++17 or C++20 to get the best experience on the site. The problem is that the two (yes, just two) C++ options I found in the compiler settings were for 1998.
I tried on a Windows 11 machine, and every option showed up as expected, such as "Have g++ follow the C++17 ISO C++ language standard [-std=c++17]" along with some slightly older versions (14, 11, etc.) which is what I was expecting to see on my Linux machine. But I don't see it.
The tutorial has some example code that you can compile to test C++17 compatibility:
#include <array>
#include <iostream>
#include <string_view>
#include <tuple>
#include <type_traits>
namespace a::b::c
{
inline constexpr std::string_view str{ "hello" };
}
template <class... T>
std::tuple<std::size_t, std::common_type_t<T...>> sum(T... args)
{
return { sizeof...(T), (args + ...) };
}
int main()
{
auto [iNumbers, iSum]{ sum(1, 2, 3) };
std::cout << a::b::c::str << ' ' << iNumbers << ' ' << iSum << '\n';
std::array arr{ 1, 2, 3 };
std::cout << std::size(arr) << '\n';
return 0;
}
I compiled this code and I got no errors. I also compiled some other code to see what C++ version I had, and it said C++17. This was the code:
#include <iostream>
int main() {
if (__cplusplus == 201703L) std::cout << "C++17\n";
else if (__cplusplus == 201402L) std::cout << "C++14\n";
else if (__cplusplus == 201103L) std::cout << "C++11\n";
else if (__cplusplus == 199711L) std::cout << "C++98\n";
else std::cout << "pre-standard C++\n";
}
If I can use C++17, why don't any new C++ versions show up in the compiler settings, and how do I fix it?
Also, please let me know if I should move this post to another category. I
think this is a compiler issue, so maybe it should be put somewhere else.
If you're wondering why I installed Code::Blocks from Flathub instead of from my system's package manager or the website, it's because Code::Blocks doesn't look very good with a dark theme, and for some reason Flatpaks just don't want to respect the system theme, so this works for Code::Blocks, I guess.