I'm trying to set up VS Code to learn C++. I downloaded the latest version of the compiler (g++) and tried running the following simple code, which (if I understand this correctly) should print a "conversion from double to float" warning:
int main(){
float f{4.1};
return 0;
}
However everything goes absolutely smooth and nothing gets printed. When I try to compile this directly through the terminal, I use the following command g++ -Wconversion myfile.cpp, the compiler goes through and the warning pops up. So I guess this is a VS Code problem.
I tried going through the tasks.json file and adding the options to show warnings, and now it looks like this
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-Wall",
"-Weffc++",
"-Wextra",
"-Wconversion",
"-Wsign-conversion",
],
"options": {
"cwd": "C:\\msys64\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
but this seems to be doing nothing.
-Werror--- you do not want to run your program if it compiles with warnings.