Checking C++03 Compilation on Windows



I have not had great success in specifically targeting C++03 using VSCode. While I continue to try and sort that out, here's something Windows users can do to check to see if code you are about to submit has any C++11 or newer syntax in it.


Consider we have a file named HelloWorld.cpp and it contains C++11 syntax:

01-HelloWorldProgram


If you are on a Windows machine AND you have followed the Install VSCode instructions, then you can do the following. Open up a Windows Command Prompt, and navigate to the directory where your source code is (in our case, the directory containing HelloWorld.cpp):


02-GoToHelloWorldDirectory


If we compile directly with G++, we'll see that there is no problem. That's because G++, by default, will use C++11 or C++14 syntax when compiling:

03-CompileWithCPP11


However, if we specify (to g++) that we'd like to build against the C++03 standard, we will get an error:


04-CompileWithCPP03



This is one way to double-check your code to make sure you haven't used C++11 or later syntax! Starting with Assignment #2, you will lose 10 points for solutions that use C++11 or later. This will be the case for every future assignment up to and including Assignment #6. After that, you will be able to use C++11 and later syntax in your solutions!