Search code examples
c++visual-studio-codewarningsvscode-code-runner

Configure VS Code code runner extension to display CPP warnings


I am wondering how I could configure the Code Runner extension on VS Code (MacOS 10.15) to display warnings (i.e. -Wall?)

Would there be a simple, almost permanent method so code runner will always display warnings no matter which CPP file I build?


Solution

  • Yes! This is possible.

    Go to the Workspace Settings, search for code runner and click on Executor Map:

    Workspace Settings for Executor Map

    You may then use the following JSON code:

    {
        "code-runner.executorMap": {
           // ...
            "c": "cd $dir && gcc $fileName -Wall -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
        }    // used -Wall here
    }
    

    Save it and quit from the file and jump to the code you want to run. Press Ctrl+Alt+J to select the run type. Select C simply and you're good to go.