N
N
Nikolay L2018-03-23 15:47:19
C++ / C#
Nikolay L, 2018-03-23 15:47:19

How to compile C code in Visual Studio Code?

Installed Microsoft C/C++ extension.
Question #2
What should I install from Visual Studio 2017 Community if I am going to write C code?
5ab4f74e59ff1533983644.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Levshits, 2019-03-18
@levshx

1. compiling on Code is a tedious process, because you need to use a compiler from outside, for debugging itself you need to create launch.json (and set the paths for GDB in it and configure the file that will be compiled, and all this is needed only for debugging, and not necessarily ) and for compiling...
... create c_cpp_properties.json in your workspace and write:

{
    "name": "Win32",
    "includePath": [
        "${workspaceFolder}"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE"
    ],
    "compilerPath": "C:\\mingw-w64\\bin\\gcc.exe",
    "intelliSenseMode": "clang-x64",
    "browse": {
        "path": [
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true,
        "databaseFilename": ""
    }
}

Pre-download mingw-w64/GCC.
I think this will not suit you, but this is not enough, you need tasks.json something like this:
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build hello world",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g", "helloworld.cpp"
            ]
        }
    ]
}

And I think you will find the parameters for your compiler yourself, from the progress in DevC`i ++, "command" is the usual execution in cmd, as far as I know for "C`i" gcc.exe will be needed, the parameters will contain paths to standard libraries and the type of application being compiled by type console or window.
2. A regular C++ project is empty, create a file with the "*.c" extension with a pen, and set the gcc or C compiler (something like that) in the project parameters

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question