9
I’m trying to run a code (program) in C in Visual Studio Code, but I can’t find the necessary settings.
- I installed the C/C++ extension (Microsoft)
Project structure:
- .vscode
- - c_cpp_properties.json
- - tasks json.
- main. c
My code:
- c_cpp_properties.json
{
"configurations": [
{
"name": "Mac",
"includePath": ["/usr/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
},
{
"name": "Linux",
"includePath": ["/usr/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
},
{
"name": "Win32",
"includePath": ["c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
}
]
}
- tasks.json
{
"version": "0.1.0",
"command": "g++",
"isShellCommand": true,
"showOutput": "always",
"args": ["-g", "main.c"]
}
- c program
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
printf("Hello World");
return 0;
}
What does that flag mean
-o
, I’ve always been curious to know if I ever asked ;) ?– MagicHat
-o
comes from-- output
, i.e., output, the output file of that build, right after that flag must indicate the name of the executable that the build will generate.– Leonardo
visual studio code compiles even python friends. and according to this tutorial: https://code.visualstudio.com/docs/languages/cpp, c and c++ also, but I’m just not being able to configure my json correctly.
– J. Marco
Actually it doesn’t have to be exactly mingw, with me Cygwin also worked, also works with cmake (although not to say if it is possible in the plugin page), I had to create two tasks, one for the cmake build and another pro make, Microsoft could simplify the VS Code environment preparation process, such as a Project Manager, for example.
– Samuel Ives