π Compile, run and debug single or multiple C/C++/Cuda files with ease. π
You do not need to know about any compiler commands. π
Make sure that your GCC/Clang compiler is either in your PATH or you have to manually set the C/C++ Compiler setting of this extension.
For Windows Users that want to use the Visual Studio compiler (called MSVC) see instructions here.
For Cuda code the NVCC Compiler will be automatically called.
1οΈβ£ Open the C/C++ file you want to compile (build).
2οΈβ£ Select either debug or release mode for building the binary (debug is the default case).
3οΈβ£ To build the binary press ctrl+alt+b.
4οΈβ£ To run the binary press ctrl+alt+r, or you can click on the play icon in the status bar down below.
5οΈβ£ To debug the binary press ctrl+alt+d, or you can click on the bug icon in the status bar down below.
1οΈβ£ Select the folder that contains the C/C++ files you want to compile.
You can select the folder by the quick pick menu from the status bar.
2οΈβ£ Optional: Select either debug or release mode for building the binary (debug is the default case).
3οΈβ£ Now you can build/run/debug the binary.
*This task is a no-op if the build task was not executed previously.
The configuration settings will be stored locally in ".vscode/settings.json".
Based on that, the local ".vscode/c_cpp_properties.json" file is created.
It will be used by Microsoft's C/C++ extension for intellisense (auto-completion etc.).
Note: You don't have to edit the c_cpp_properties.json file.
To use the Visual Studio MSVC compiler, e.g. VS2022, set the msvcBatchPath setting to a valid path.
As an example installation path of the compiler:
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat".
Then set the useMsvc extension setting to true, to use MSVC and not GCC/Clang.
If you want to stop using the MSVC compiler, just set useMsvc to false.
β οΈ Only the 64-bit (no cross-compiling) version of MSVC is supported.
β οΈ The extension is only tested for VS2019 and VS2022.
β οΈ For auto detecting the installed VS you have to install it in C:/Program Files/Microsoft Visual Studio
You can pass in command-line arguments for running or debugging the binary.
Make sure to select the active folder that should be compiled beforehand.
Then press ctrl+alt+a
to open the message box to type in the arguments:
These arguments will be stored in the launch.json config for debugging the binary.
If you now run or debug your program these values will be fed into argc/argv.
Important: The stored arguments will be reset after selecting a new active folder.
Note: For strings with whitespaces please use \" (not single \').
You can add glob patterns to include and exclude folders from the folder selection.
Note: The include pattern is used before the exclude pattern.
For example with the following exclude glob pattern:
The folder selection would change from left to right.
When executing the command: Generate Assembler Code.
The assembler code will be generated in a .s file that will be in the build directory next to the executable.
π·π» Note: Currently, this feature is experimental and only works for single-file builds.
The extension buttons are hidden if there is a CMakeLists.txt in the workspace root directory.
This prevents an overloaded status bar with a lot of icons due to Microsoft's CMake extension.
However, the user can trigger the start-up of this extension by executing the command: Toggle extension buttons in status bar.
Refer to the CHANGELOG.
Copyright (C) 2021-2023 Jan Schaffranek.
Licensed under the MIT License.
Feel free to donate, such that I have more time to work on my VSCode extensions.
Or use the Link: https://www.paypal.com/donate/?hosted_button_id=3WDK6ET99ZQCU