C/C++ for VS Code

Getting Started

To install the Microsoft C/C++ extension:
  • Open VS Code.
  • Click the Extensions View icon on the Sidebar.
  • Search for cpptools.
  • Click Install, then click Enable.
  • Open a folder that contains your C/C++ code.
You should now create a tasks.json file in your workspace .vscode folder that looks something like:
{
"version": "0.1.0",
"command": "gcc",
"isShellCommand": true,
"showOutput": "always",
"args": ["-g","FILENAME.c"]
}
 After that you can generate a.out file by pressing CTRL+SHIFT+B.

To enable debugging, you will need to create a launch.json file in .vscode folder : 

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "/PATH/TO/WORKSPACE",
            "environment": [],
            "externalConsole": true,
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        },
        {
            "name": "C++ Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "${workspaceRoot}/a.out",
            "processId": "${command.pickProcess}",
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        }
    ]
}

Comments

Popular posts from this blog

How To Make IoT Messaging with BashShell

How To Make IoT Tweet with Python