Home >Backend Development >C++ >How Can I Fix C 17 `std::string_view` Errors in VSCode?
Empowering C 17 Support in VSCode C Extension
Encountering persistent error squiggles on std::string_view despite successful builds often stems from a mismatch between the C standard used by VSCode's C extension and your code's requirements. To rectify this, navigate to "cppstandard" within your VSCode extension settings and select the desired C version.
For a seamless debugging experience, ensure that your tasks.json configuration aligns with your chosen C version. Here's an example tailored for C 17:
{ "tasks": [ { "type": "cppbuild", "label": "C/C++: g++ build active file", "command": "/usr/bin/g++", "args": [ "-std=c++17", "-I", "${fileDirname}", "-g", "${fileDirname}/*.cpp", "-o", "${workspaceFolder}/out/${fileBasenameNoExtension}.o" ], "options": { "cwd": "${workspaceFolder}" }, "problemMatcher": ["$gcc"], "group": { "kind": "build", "isDefault": true } } ], "version": "2.0.0" }
Remember, if you're using the provided tasks.json directly, establish an "out" directory in your workspace root for successful compilation.
The above is the detailed content of How Can I Fix C 17 `std::string_view` Errors in VSCode?. For more information, please follow other related articles on the PHP Chinese website!