Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a project in Visual Studio 2015 in C++98 mode

I currently have a project which I programmed in Visual Studio 2015 with the most up to date compiler (i.e. the default). Unfortunately, I require my project to compile and execute in a C++98 environment - is there a way for me to do this in Visual Studio by somehow changing the compiler version so that I can check that my project still works?

Also, within this project I am using FLTK 1.3.3 (a GUI package) - will I be required to rebuild this library using C++98 mode if I can indeed do this in Visual Studio 2015?

like image 476
sjrowlinson Avatar asked Dec 15 '15 18:12

sjrowlinson


People also ask

How do I run C code in Visual Studio?

Download & Install the C/C++ Extension We need to click on the extension button that displays a sidebar for downloading and installing the C/C++ extension in the visual studio code. In the sidebar, type C Extension. In this image, click on the Install button to install the C/C++ extension.

How can I change C++ compiler in Visual Studio?

In Visual Studio You can set compiler options for each project in its Visual Studio Property Pages dialog box. In the left pane, select Configuration Properties, C/C++ and then choose the compiler option category.

How do I run a CPP file in Visual Studio?

Build and run your code in Visual Studio To build your project, choose Build Solution from the Build menu. The Output window shows the results of the build process. To run the code, on the menu bar, choose Debug, Start without debugging. A console window opens and then runs your app.

How do I select C++ version in Visual Studio?

To set this compiler option in the Visual Studio development environment. Open the project's Property Pages dialog box. For more information, see Set C++ compiler and build properties in Visual Studio. Select the Configuration Properties > C/C++ > Language property page.


2 Answers

Short answer is no. You cannot change the cl.exe that VS compiles with. You can set up a makeile project to use an older version of mingw or similar though:

Can I force visual studio to use mingw compiler

Here is some information about creating a makefile project.

like image 140
Fantastic Mr Fox Avatar answered Sep 28 '22 19:09

Fantastic Mr Fox


Clang with Microsoft CodeGen in VS 2015 Update 1

You might want to check out a new feature of Visual Studio 2015 Update 1, clang/c2 (clang frontend with Microsoft c2 codegen).

You should be able to use -std=c++98 -pedantic flags, and thus to force C++98 mode. However you will need to recompile every C++ library you use, with this toolchain (C libraries should theoretically work though).

Note that compiling in standard compliant mode does not guarantee that you will be able to compile your program with compilers of that era. C++ compilers of those dark days was rarely standard compliant. You might want to pick a concrete compiler and check everything directly.

like image 30
Ivan Aksamentov - Drop Avatar answered Sep 28 '22 19:09

Ivan Aksamentov - Drop