I have to write my assignment in C but I don't want to download a new IDE just for this course. I want to use VS 2019 and MSVC to compile it, but I would like to generate errors for things that aren't in C. Is this possible?
By default, MSVC will compile files with the .c
extension as "C" and files with the .cpp
extension as "C++". However, if (for whatever reason) this does not seem to be the case, you can specify which language to use on a project-basis (or even on an individual source file basis).
To do this, right-click on the project in the Solution Explorer and select the "Properties" command. In the displayed dialog box, open the C/C++
node and select the Advanced
item; then, choose "Compile as C Code" in the Compile As
property. Like this:
You can do the same for an individual file within a project by right-clicking on that file, rather than on its containing project.
NOTE: The plain "C" compiler native to Visual Studio (MSVC) uses a very old language standard. You may find the clang-cl plug-in very useful, as that complies to a more modern standard (it uses the LLVM compiler). You can install it via the "Visual Studio Installer" program (if you have VS-2019).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With