I'm trying to run a code (program) in C in Visual Studio Code, but I can not find the necessary settings.
- I installed the C / C ++ (Microsoft) extension
Project structure:
.vscode - c_cpp_properties.json - tasks.json main.c
My code: link
I'm trying to run a code (program) in C in Visual Studio Code, but I can not find the necessary settings.
Project structure:
.vscode - c_cpp_properties.json - tasks.json main.c
My code: link
VSCode, although an editor and not an IDE, allows you to compile code through some plugins. In the case of compiling C / C ++ code in Windows, I find it a bit "boring". It took me a week to set up.
Even though the question was asked more than a year ago, I think some people might find this and I may have helped in some way.
What I did to compile the C code was to install the Microsoft C / C ++ plugin
After installing the plugin, download and install MingGW with the gcc functions for Windows.
In VSCode, create or edit the c_cpp_properties.json file, to edit just use the shortcut Ctrl + Shift + P and select "C / Cpp: Edit Configurations".
Remember that the file version quoted below may change.
{
"configurations": [
{
"name": "Win32",
"intelliSenseMode": "clang-x64",
"includePath": [
"${workspaceRoot}",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/mingw32",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/backward",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include",
"C:/MinGW/include",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed"
],
"defines": [
"_DEBUG",
"UNICODE",
"__GNUC__=6",
"__cdecl=__attribute__((__cdecl__))"
],
"browse": {
"path": [
"C:/MinGW/lib/gcc/mingw32/6.3.0/include",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed",
"C:/MinGW/include/*"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
]
}
For C language, not C ++, just remove some lines, as below:
{
"configurations": [
{
"name": "Win32",
"intelliSenseMode": "clang-x64",
"includePath": [
"${workspaceRoot}",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include",
"C:/MinGW/include",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed"
],
"defines": [
"_DEBUG",
"UNICODE",
"__GNUC__=6",
"__cdecl=__attribute__((__cdecl__))"
],
"browse": {
"path": [
"C:/MinGW/lib/gcc/mingw32/6.3.0/include",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed",
"C:/MinGW/include/*"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
]
}
After performing this configuration, you only add "C_Cpp.intelliSenseEngine": "Default"
to your user settings.
Then just write the code and run it with the Code Runner plugin.
Source: Microsoft GitHub
Visual Studio Code is a text editor, not an IDE, it has no compiler. You can compile through the terminal (if you use Linux or Mac):
gcc -o executavel main.c
Man, I need these settings, not everything. Just install Microsoft's C module. ctl + shift + 'to open the terminal. It already opens in the file folder.
$ g ++ testC.cpp -o testC
$ ./testeC Where testC.cpp is the name of your static with extension (in C would be: testC.c)
My personal opinion about programming in C, C ++ is best to install code :: blocks (Windows, Linux or Mac).