How to make VSCODE show gcc output when compiling

Viewed 215

I'm trying to edit my tasks.json and/or launch.json to output warnings gcc would usually show when compiling C code with -Wall and -Wextra flags using Run Without Debugging.

When using the the Run Without Debugging option in VSCODE it seems to compile the program using the flags set in my workspace tasks.json file but it doesn't show me the output of gcc. There's a Task - build active file-tab in the terminal section but it just shows:

> Executing task: C/C++: gcc build active file <

Starting build...

Build finished successfully.

Terminal will be reused by tasks, press any key to close it.

Example code:

#include <stdio.h>

int main(void)
{
    int ten = 10;
    int two = 2;

    printf("Doing it right:\t");
    printf("%d minus %d is %d\n\n", ten, 2, ten - two);

    printf("Doing it wrong:\t");
    printf("%d minus %d is %d\n",ten); // Two arguments missing

    return 0;
}

Example of the desired output upon compiling:

example.c: In function ‘main’:
example.c:13:23: warning: format ‘%d’ expects a matching ‘int’ argument [-Wformat=]
   13 |     printf("%d minus %d is %d\n",ten); // Two arguments missing
      |                      ~^
      |                       |
      |                       int
example.c:13:29: warning: format ‘%d’ expects a matching ‘int’ argument [-Wformat=]
   13 |     printf("%d minus %d is %d\n",ten); // Two arguments missing
      |                            ~^
      |                             |
      |                             int
0 Answers
Related