Home >Backend Development >C++ >How to Change the C Language Standard in VS Code with CodeRunner?

How to Change the C Language Standard in VS Code with CodeRunner?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-12-09 09:31:06186browse

How to Change the C   Language Standard in VS Code with CodeRunner?

Changing C Language Standard in VS Code with CodeRunner

Visual Studio Code defaults to C 98 for execution when using the CodeRunner extension. However, you can easily switch to a different C language standard, such as C 17 or C 20.

Solution:

  1. Open the Extensions panel in VS Code.
  2. Search for "ms-vscode.cpptools" and click on the C/C extension.
  3. Click on the gear icon next to "Uninstall."
  4. Select "Extension Settings" from the dropdown menu.
  5. Locate the search bar and type "cppStandard."
  6. Change the value of "Cpp Standard" to the desired version, such as "c 17" or "c 20."

Once you make the adjustment, the C files will be executed using the selected language standard. To verify, you can include the following code in a C file:

#include <iostream>

int main() {
  if constexpr (sizeof(int) == 4) // C++11 feature
    std::cout << "int is 32 bits" << std::endl;
  return 0;
}

With C 17 selected, the code will correctly output that "int is 32 bits," confirming the change in language standard.

The above is the detailed content of How to Change the C Language Standard in VS Code with CodeRunner?. 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