Skip to content

Instantly share code, notes, and snippets.

@zawie
Forked from akanshgulati/tasks.md
Last active February 10, 2021 13:27
Show Gist options
  • Save zawie/9fc84aac86286d8a59f1c3ea1760d74f to your computer and use it in GitHub Desktop.
Save zawie/9fc84aac86286d8a59f1c3ea1760d74f to your computer and use it in GitHub Desktop.
Visual Studio Code task to compile and run C programs

Introduction

The below code is the configuration for the Microsoft Visual Code tasks which will enable you to compile and run C program

Steps

  1. Press Cmd + Shift + P
  2. Type Configure task ( A task.json file will be created for that project )
  3. Copy below configuration code and save it.

Usage

Simple press Cmd + Shift + B to compile and run.

Note: Make sure you select the tab having C program as below tasks run on active tab in VS Code.

Task Config

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "compile and run C",
            "type": "shell",
            "command": "cc -std=gnu11 -Wall -Wextra -Werror ${file} -o ${fileBasenameNoExtension}  &&   ./${fileBasenameNoExtension} ",
            "presentation": {
                "reveal": "always",
                "panel": "shared"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment