0

i just now noticed that my gcc version is 6.3.0, which doesnt support c++17 standard. i tried to update it with mingw-get update and mingw-get upgrade commands on command prompt, but after running gcc -v it seems to still be on the same version, and when i use the testing code for c++17 compliance which goes as follows:

#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;
}

which wont build because string_view isnt recognized despite having c++17 compliance option checked in codeblocks compiler settings, which draws me to the only conclusion that my gcc is outdated. excuse me if there are any technical fallacies in my post, i am new.

  • 2
    Use msys2 to install MinGW with g++-12.2: [https://www.msys2.org/#installation](https://www.msys2.org/#installation) it also comes with a package manager pacman which makes installing many open source libraries very easy. There is this question that should help: [https://stackoverflow.com/questions/30069830/how-can-i-install-mingw-w64-and-msys2](https://stackoverflow.com/questions/30069830/how-can-i-install-mingw-w64-and-msys2) – drescherjm Dec 18 '22 at 03:10
  • when i check for the gcc version in msys2 console it says its the newest one i previously installed with pacman but when i check in cmd it once again says 6.3.0 and codeblocks still wont build – crazierman 50 Dec 18 '22 at 03:54
  • You probably want to remove your old MinGW and edit your compiler settings in Code::Blocks to point to `C:\msys64\mingw64\bin` The instructions for doing that are here: [https://stackoverflow.com/questions/36972968/how-can-use-mingw-w64-and-msys2-with-any-ide-like-eclipse-or-codeblocks](https://stackoverflow.com/questions/36972968/how-can-use-mingw-w64-and-msys2-with-any-ide-like-eclipse-or-codeblocks) – drescherjm Dec 18 '22 at 03:57
  • yeah i managed to update it but the testing code still refuses to build even with gcc 12.2.0 still not recognized. i thought it should work on gcc 7+ – crazierman 50 Dec 18 '22 at 04:27
  • The default may still be c++14 I am not sure you may need to use -std=c++17. Edit: This question helped me figure out the default is c++17: [https://stackoverflow.com/questions/44734397/which-c-standard-is-the-default-when-compiling-with-g](https://stackoverflow.com/questions/44734397/which-c-standard-is-the-default-when-compiling-with-g) – drescherjm Dec 18 '22 at 04:30
  • I tested that using the most popular answer and also the one that used man after installing man in msys2 [https://packages.msys2.org/package/man-db](https://packages.msys2.org/package/man-db) – drescherjm Dec 18 '22 at 04:36
  • Ensure that cmd says that "'gcc' is not recognized as an internal or external command, operable program or batch file." IDE should be capable to find it without it being in PATH. – Öö Tiib Dec 18 '22 at 04:37

0 Answers0