This work is licensed under a
Creative Commons Attribution-ShareAlike 4.0 International License
This document was written for VisualStudio Code 1.57.1 and tested on macOS 11.5.1 Big Sur.
Microsoft documentation for VSCode C/C++
@"Hello world!\r\n"
”launch.json
” that is somehow part of your VSCode project. Great../hello
just like I would from the mac Terminal (or from my old VT100 back in the day).Open Preferences (from the application menu in macOS, somewhere else on other platforms)
Select “Settings”
It seems like you can have per-user and per-workspace settings using the tabs in the top-left of the Settings pane
Look for “C_cpp > Default: C Standard” and select “c99” from the menu
I then found “C_cpp > Default: Compiler Args” and there’s a link that says “Edit in settings.json”. Ok...
Put the following between the square brackets (which denotes a JSON list): "-Wall", "-Werror"
. Be sure to include the quote marks. You are adding two strings to that list.
Save the file.
I went back to hello.c
and clicked the green play button at the top-left, but I don’t see those compiler arguments in the console output.
Hmmm...
For CSC173: Do not submit code that does not compile with the required compiler arguments!
Update: It seems like the file tasks.json
in the .vscode
directory specifies the arguments for the compiler. So you could edit that (JSON) to include the required options as strings after “-g
” and before “${file}
” which is presumably the name of the file being compiled (really? just one file?).
Yes, now I see those options in the Terminal output after I click the green play button.
So what was that other stuff about???