Home >Backend Development >C++ >How to Configure VS Code with Code Runner for C 14/C 17?

How to Configure VS Code with Code Runner for C 14/C 17?

DDD
DDDOriginal
2024-12-11 21:04:12588browse

How to Configure VS Code with Code Runner for C  14/C  17?

Using code-runner to Setup VS Code for C 14 /C 17

You may encounter errors while running C files in VS Code related to using C 14 or C 17 features. Follow these steps:

1. Install "Code Runner" Extension:
Install the "Code Runner" extension from the VS Code Marketplace. This extension provides convenient execution of code.

2. Modify "settings.json":
Open your settings.json file (File > Preferences > Settings). Add the following:

"code-runner.executorMap": {
    "cpp": "cd $dir & g++ -std=c++17 $fileName -o $fileNameWithoutExt & $dir$fileNameWithoutExt",
},

This configuration specifies the C compiler command with the -std=c 17 flag.

3. Run with "Code Runner":
Instead of using the built-in terminal, use the "Code Runner" shortcut (Ctrl Alt N by default) or go to Run > Code Runner > Run from Terminal.

With these changes, VS Code will use the correct C 14/C 17 standard and handle the execution of your code more effectively.

The above is the detailed content of How to Configure VS Code with Code Runner for C 14/C 17?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn