To set up Visual Studio Code (VS Code) for C 14 or C 17, follow these steps:
Install the "C/C " extension from the VS Code Marketplace. This extension provides basic C support, including syntax highlighting and code completion.
VS Code requires a C compiler to build and run C code. Install a C compiler, such as MinGW or Clang, and add it to your path.
In VS Code, open the "Settings" tab and search for "C/C : Compiler Path." Set this setting to the path of the C compiler you installed.
In the "Settings" tab, search for "C/C : C Standard." Select the C standard you want to use, such as "c 14" or "c 17."
The Code Runner extension simplifies running C code from VS Code. Install this extension and add the following code to your "settings.json" file:
"code-runner.executorMap": { "cpp": "cd $dir && g++ -std=c++17 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt" }
If you encounter this error while trying to run a C file with C 14 or C 17 syntax, you need to ensure that the C standard is correctly set in your VS Code settings. Follow the steps in section 3 to verify the C standard setting.
If the error persists, try using the Code Runner extension and the settings provided in section 5. This method may bypass the issue and allow you to run your C code.
The above is the detailed content of How to Configure VS Code for C 14/C 17 Development?. For more information, please follow other related articles on the PHP Chinese website!