Reputation: 493
I'm running g++ compiler on windows 10 with mingw. On checking compiler version in cmd I get the following:
g++ --version- g++ (MinGW.org GCC Build-2) 9.2.0
same with c++ --version
When I compiled a cpp program making use of structured bindings I got a warning:
warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
But otherwise the code ran fine. Does everyone get this warning or am I running a lower version compiler?
I'm using an extension - Competitive programming helper, and this warning interrupts the process. Hence, if it is the case that everyone gets this warning, is there a way I can block version specific warnings only without having to block all compiler warnings.
TIA.
Upvotes: 0
Views: 4073
Reputation: 84
As the warning itself says:
structured bindings only available with '-std=c++17' or '-std=gnu++17'.
Meaning, you are using cpp version 14 or lower as compiler. However, you also have cpp 17 or higher installed on your system to get such kind of warning.
Your program will still run but with the warning.
For Windows:
If you are using VS code (assuming that you are already using code runner) then,
Ctrl + ,
)It is finally done now.
Below steps are for linux.
sudo gedit ~/.bashrc
in terminal.alias g++="g++ --std=c++2a"
at the end of the file.
Once done, you will not get any warning.
Note:
It is not mandatory to use cpp+20. You can use any version you like.
Change the version according to this website
https://www.learncpp.com/cpp-tutorial/configuring-your-compiler-choosing-a-language-standard/
Upvotes: 4