7

Is it possible to use an older version in Visual Studio than c++11? A similar question revealed that it is not possible to use a newer version, but I want the compiler to complain when I am using language features that are only available for c++11.

Kackao
  • 1,181
  • 3
  • 13
  • 22
  • 2
    Simply set the platform tool set in the project properties – paulm May 21 '15 at 11:11
  • Alternatively, install some recent [GCC](http://gcc.gnu.org/) variant - 4.9 or better; or some recent [Clang/LLVM](http://clang.llvm.org/) (perhaps thru [cygwin](https://cygwin.com/), [mingw](http://mingw.org/), or by installing a Linux distribution). Then compile with `g++ -std=c++98` or `clang++ -std=c++98` .... Don't forget to ask for all warnings & debug info `-Wall -Wextra -g` – Basile Starynkevitch May 21 '15 at 11:15

2 Answers2

3

To completely disable C++11 features in Visual Studio, you must compile with a toolset old enough that it does not have any C++11 features. The last version of Visual Studio to have no C++11 support was VS2008 (question about that here: Visual Studio 2008 with c++11).

To use an older toolset, you must first install that version of Visual Studio, and then modify the "Configuration Properties->General->Platform Toolset" and set it to the appropriate Visual Studio version. When you compile with Visual Studio 2008 toolset, any C++11 usage will be errors.

Community
  • 1
  • 1
MuertoExcobito
  • 9,741
  • 2
  • 37
  • 78
  • But that requires VS2008 to be installed. – Ajay May 21 '15 at 12:13
  • that's why I said: "To use an older toolset, you must first install that version of Visual Studio" :) – MuertoExcobito May 21 '15 at 12:21
  • 1
    I get that this "hack" means you can do it from your new IDE, but really this is just saying "no, use an older version of VS"! – Lightness Races in Orbit May 21 '15 at 12:50
  • @LightnessRacesinOrbit true, but, it's the best answer for the question that's asked. If you like the newer IDEs better, or you need the newer one because it has features/plugins that don't support older versions, then it does provide some advantage over simply using MSVC 2008. It would be nice if MSVC would be more flexible/complete with compiler features and backwards compatibility (like gcc), but, it's just not. – MuertoExcobito May 21 '15 at 13:32
  • This seems to work. Another solution I came across is using Makefiles to compile. – Kackao May 22 '15 at 12:02
0

No, there is no way to disable C++11 features for a Visual Studio project without installing an older MSVC version.

Antwane
  • 20,760
  • 7
  • 51
  • 84