vscode-cpptools
Official repository for the Microsoft C/C++ extension for VS Code.
Top Related Projects
The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
IntelliJ IDEA Community Edition & IntelliJ Platform
The Swift Programming Language
clangd language server
Mirror of CMake upstream repository
Quick Overview
The microsoft/vscode-cpptools repository contains the C/C++ extension for Visual Studio Code. This extension provides IntelliSense, debugging, and code browsing capabilities for C and C++ in VS Code, enhancing the development experience for C/C++ programmers.
Pros
- Robust IntelliSense support for C and C++
- Integrated debugging capabilities
- Cross-platform compatibility (Windows, macOS, Linux)
- Regular updates and active maintenance by Microsoft
Cons
- Can be resource-intensive on larger projects
- Configuration can be complex for some setups
- Occasional issues with auto-completion accuracy
- Limited support for some less common C++ dialects
Getting Started
- Install Visual Studio Code
- Open VS Code and navigate to the Extensions view (Ctrl+Shift+X)
- Search for "C/C++" and install the Microsoft C/C++ extension
- Create or open a C/C++ project in VS Code
- Configure your project using the
c_cpp_properties.json
file - Start coding with IntelliSense and debugging support
For more detailed setup instructions, refer to the official documentation at https://code.visualstudio.com/docs/languages/cpp
Competitor Comparisons
The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
Pros of llvm-project
- Comprehensive toolchain: Includes compiler, debugger, and various tools for C/C++ development
- Highly optimized and widely used in production environments
- Supports multiple programming languages beyond C/C++
Cons of llvm-project
- Steeper learning curve for beginners
- Larger codebase and more complex setup process
- Less integrated with specific IDEs or editors
Code Comparison
vscode-cpptools:
{
"configurations": [
{
"name": "Win32",
"includePath": ["${workspaceFolder}/**"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
llvm-project:
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/IRBuilder.h"
LLVMContext Context;
Module *M = new Module("MyModule", Context);
IRBuilder<> Builder(Context);
Function *F = Function::Create(FunctionType::get(Type::getVoidTy(Context), false),
Function::ExternalLinkage, "main", M);
IntelliJ IDEA Community Edition & IntelliJ Platform
Pros of intellij-community
- More comprehensive IDE features, including advanced refactoring tools and code analysis
- Supports a wider range of programming languages and frameworks out-of-the-box
- Offers a unified development environment with integrated build tools and version control
Cons of intellij-community
- Heavier resource consumption, potentially slower on less powerful machines
- Steeper learning curve due to more complex UI and extensive feature set
- Requires more setup time compared to the lightweight nature of VS Code
Code Comparison
intellij-community (Java):
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
vscode-cpptools (C++):
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
While both repositories provide tools for code editing and development, they cater to different needs. intellij-community offers a full-fledged IDE experience with extensive features, while vscode-cpptools focuses on providing C/C++ support for the lightweight VS Code editor. The choice between them depends on the user's specific requirements, development environment preferences, and the programming languages they primarily work with.
The Swift Programming Language
Pros of Swift
- Designed specifically for Apple platforms, offering seamless integration with iOS, macOS, and other Apple ecosystems
- More modern language design with features like optionals, generics, and protocol-oriented programming
- Faster compilation times and improved performance compared to Objective-C
Cons of Swift
- Limited cross-platform support compared to C/C++
- Smaller community and ecosystem compared to C/C++
- Frequent language changes and updates can lead to compatibility issues
Code Comparison
Swift:
let numbers = [1, 2, 3, 4, 5]
let doubled = numbers.map { $0 * 2 }
print(doubled)
C++ (vscode-cpptools):
#include <vector>
#include <algorithm>
#include <iostream>
std::vector<int> numbers = {1, 2, 3, 4, 5};
std::vector<int> doubled;
std::transform(numbers.begin(), numbers.end(), std::back_inserter(doubled), [](int x) { return x * 2; });
The Swift code is more concise and readable, showcasing its modern language features. The C++ code, while more verbose, demonstrates the power and flexibility of the Standard Template Library (STL) in vscode-cpptools.
Pros of gcc
- Comprehensive C/C++ compiler suite with extensive language support
- Highly optimized code generation for multiple architectures
- Large community and long-standing development history
Cons of gcc
- Steeper learning curve for configuration and usage
- Lacks integrated development environment features
- Primarily command-line based, which may be less user-friendly for some developers
Code comparison
gcc example:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
vscode-cpptools example:
{
"name": "gcc build active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}"
}
Summary
While gcc is a powerful compiler suite with extensive optimization capabilities, vscode-cpptools provides a more user-friendly development environment with integrated debugging and IntelliSense features. gcc excels in performance and cross-platform support, while vscode-cpptools offers a smoother experience for developers, especially those new to C/C++ programming. The choice between the two depends on the specific needs of the project and the developer's preferences.
clangd language server
Pros of clangd
- Faster and more accurate code completion and diagnostics
- Language-agnostic, supporting multiple C-family languages
- Better integration with LLVM toolchain
Cons of clangd
- Steeper learning curve for configuration
- Less out-of-the-box functionality for specific C++ workflows
Code Comparison
clangd:
{
"clangd.path": "/path/to/clangd",
"clangd.arguments": [
"--background-index",
"--clang-tidy"
]
}
vscode-cpptools:
{
"C_Cpp.intelliSenseEngine": "Default",
"C_Cpp.default.compilerPath": "/path/to/compiler",
"C_Cpp.default.includePath": [
"${workspaceFolder}/**"
]
}
Both repositories provide C/C++ language support for editors, but clangd offers a more powerful and flexible solution with its LLVM-based architecture. It excels in performance and accuracy, making it ideal for large-scale projects. However, vscode-cpptools provides a more user-friendly experience with easier setup and configuration, especially for Visual Studio Code users. The choice between the two depends on the specific needs of the project and the developer's familiarity with the tools.
Mirror of CMake upstream repository
Pros of CMake
- Cross-platform build system generator, supporting a wide range of compilers and IDEs
- Powerful scripting language for complex build configurations
- Large ecosystem with extensive documentation and community support
Cons of CMake
- Steeper learning curve compared to vscode-cpptools
- Requires separate configuration files, unlike vscode-cpptools' integrated approach
- Less seamless integration with Visual Studio Code out-of-the-box
Code Comparison
CMake example:
cmake_minimum_required(VERSION 3.10)
project(MyProject)
add_executable(MyApp main.cpp)
vscode-cpptools example (c_cpp_properties.json):
{
"configurations": [
{
"name": "Win32",
"includePath": ["${workspaceFolder}/**"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
CMake is a versatile build system generator, while vscode-cpptools focuses on providing C/C++ language support within Visual Studio Code. CMake offers more flexibility for complex projects but requires additional setup, whereas vscode-cpptools provides a more integrated development experience within VS Code.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
C/C++ for Visual Studio Code
Repository | Issues | Documentation | Code Samples
The C/C++ extension adds language support for C/C++ to Visual Studio Code, including editing (IntelliSense) and debugging features.
Pre-requisites
C++ is a compiled language meaning your program's source code must be translated (compiled) before it can be run on your computer. VS Code is first and foremost an editor, and relies on command-line tools to do much of the development workflow. The C/C++ extension does not include a C++ compiler or debugger. You will need to install these tools or use those already installed on your computer.
- C++ compiler pre-installed
- C++ debugger pre-installed
Here is a list of compilers and architectures per platform officially supported by the extension. These are reflected by the available IntelliSense modes from the extension's IntelliSense configuration. Note that support for other compilers may be limited.
Platform | Compilers | Architectures |
---|---|---|
Windows | MSVC, Clang, GCC | x64, x86, arm64, arm |
Linux | Clang, GCC | x64, x86, arm64, arm |
macOS | Clang, GCC | x64, x86, arm64 |
For more information about installing the required tools or setting up the extension, please follow the tutorials below.
Overview and tutorials
C/C++ extension tutorials per compiler and platform
- Microsoft C++ compiler (MSVC) on Windows
- GCC and Mingw-w64 on Windows
- GCC on Windows Subsystem for Linux (WSL)
- GCC on Linux
- Clang on macOS
Quick links
- Editing features (IntelliSense)
- IntelliSense configuration
- Enhanced colorization
- Debugging
- Debug configuration
- Enable logging for IntelliSense or debugging
Questions and feedback
FAQs
Check out the FAQs before filing a question.
Provide feedback
File questions, issues, or feature requests for the extension.
Known issues
If someone has already filed an issue that encompasses your feedback, please leave a ð or ð reaction on the issue to upvote or downvote it to help us prioritize the issue.
Quick survey
Let us know what you think of the extension by taking the quick survey.
Contribution
Contributions are always welcome. Please see our contributing guide for more details.
Microsoft Open Source Code of Conduct
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Data Collection
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry via the same setting provided by Visual Studio Code: "telemetry.enableTelemetry"
. Our privacy statement is located here. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoftâs Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-partyâs policies.
Top Related Projects
The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
IntelliJ IDEA Community Edition & IntelliJ Platform
The Swift Programming Language
clangd language server
Mirror of CMake upstream repository
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot