Currently I am using C++ in Windows environment. I am using Visual Studio 2008 with Service pack 1.
I never thought about C++ version unless until I came to know about C++11. There appear to be different versions like ANSI standard, C++ 98 Standard etc.
How do I get to know which version of C++ am I using?
If I don't have Visual Studio I know I can use other Compilers like TC to compile my C++ code. In that case how can I get to know which version of C++ the compiler is using.
Are the changes made in consecutive C++ versions about Programming concepts or only in Language design?
It's not as simple as a version check.
Every compiler that supports some C++11 supports a different subset of C++11. No compiler advertises full compliance with C++11 yet, for obvious reasons.
The C++11 specification requires that a predefined macro, __cplusplus be defined which has the value 201103L. However, you cannot rely on this macro alone. Not in real code.
You instead have to rely on compiler-specific macros to tell when compiler and which version of that compiler you're using. Or you can use Boost.Config to help you detect whether specific features are supported.
Visual Studio 2008? You can forget C++11.
Visual Studio 2010 has some C++11 but it's buggy.
Visual Studio 2012 has better C++11 for some features, but others are missing.
Visual Studio 2013 has new support for variadic templates and other features.
But VS is behind other compilers such as gcc in C++11 support.
You can download free express editions for all these versions.
Related
As cited here Visual c++ 2013 supports most of c++11, plus some extra features and some changes. However, I need to be able to write and compile strictly in c++11. Is there a package that only contains c++11 headers or some other setting that I can implement to make visual studio work in c++11? I have looked at this link question but it isn't exactly what I want. Also I do not have an older version to change the framework to as suggested. Thank you.
No, you can't do that. Compliance to C++11 isn't just a matter of headers. It requires a fully-compliant compiler. If you use VS2013, you'll need to settle for the supported subset of C++11 features.
Can I set the Visual Studio compiler to conform to a specific version of c++ (e.g. C++03 or C++11)? If so, how?
I'm using Visual Studio 2010.
No, you can't. Pretty much the only flag for controlling the language is /Za (don't use Microsoft extensions), and that's so broken that the MS STL isn't even tested with it, and parts might not compile - not to mention the Windows SDK headers.
VS2010 obviously can not be set to C++11 compatibility. (less obviously 2012 can't be either...)
As for C++03 it is fairly compatible, you can find the short list of differences in msdn. Also the options to turn off extensions, though that switch has no practical use.
How to check the version of C++ in Visual C++ Express Edition 2010 and change it to C++11?
I've tried to use uniform initialization like std::vector<std::string> v{"Hello" , "World"};, but it doesn't work.
You cannot change the C++ language version used by Visual Studio 2010. It does have partial support for C++11, but since VS 2010 was released before the C++11 standard was finalized, certain features are not exactly in-line with the standard, and furthermore not all features have been implemented.
See this chart for a list of which C++11 features are supported in various major compilers and the versions at which they became available.
Unfortunately, that is not implemented in the compiler yet, not even in VS 2012.
Visual C++ does not support uniform initialization at present time. The most recent compiler CTP release (for Visual Studio 2012, not 2010) has support for it, but that is an alpha-quality product. Moreover, there is no standard library support in there yet, so you still wouldn't be able to use uniform initialization with vector.
(In any case, how would you expect C++2011 to be supported on MSVC++2010?)
I am currently using Visual Express C++ (2010) for my project, but I am looking at features in C++11 (thread support). This does not seem to be supported in Express 2010.
From my research so far it looks like I will need Visual Express C++ 2012 version to get support for this (http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx)?
Cite from this page:
In VC11, we intend to completely support the C++11 Standard Library, modulo not-yet-implemented compiler features. (Additionally, VC11
won't completely implement the C99 Standard Library, which has been
incorporated by reference into the C++11 Standard Library. Note that
VC10 and VC11 already have .) Here's a non-exhaustive list
of the changes we're making:
New headers:
<atomic>, <chrono>, <condition_variable>, <future>,<mutex>, <ratio>,
<scoped_allocator>, and <thread>.
So in summary:
What are my options to get Visual Express with <thread> support?
To get support for Visual Studio Express you either need Visual Studio Express 2012, or you can purchase my Just::Thread library, which provides the C++11 thread library for MSVC 2005 and later on Windows, and various versions of gcc across Windows, Linux and MacOSX.
Well here's a rather stupid question. Is Visual C++ JUST an IDE?? Or is it a language on its own for win32? What exactly would be the difference between the two? This I ask because I was trying out some of my old C++ code on VC++ 2008 and it wouldn't compile.
Visual C++ can be many things, including:
Microsoft's C++ compiler (cl.exe, link.exe etc)
The IDE (Visual Studio in C++ mode)
The C runtime (MSVCRT)
Other libraries (less so): MFC, ATL
As for compiling old C++ code: Visual Studio is now a fairly compliant C++ compiler. This was not always the case, such as with Visual C++ 6 or earlier. It is likely your code is not standards compliant or uses deprecated behavior, which simply doesn't work on newer compilers.
Note: this paragraph is outdated: Visual C++ is unfortunately a poor C compiler, as it does not support C99 (and never will), unless features overlap between C++ and C99. The most notable issue for many people is the lack of stdint.h.
Visual C++ supports C11 and C17 starting with Visual Studio 2019 version 16.8 Preview 3
For many years Visual Studio has only supported C to the extent of it
being required for C++. Things are about to change now that a
conformant token-based preprocessor has been added to the compiler.
With the advent of two new compiler switches, /std:c11 and /std:c17,
we are officially supporting the latest ISO C language standards.
Visual C++ is an IDE. It compiles standard C++ code. However, every C++ compiler essentially creates its own version of C++. Few compilers are entirely compliant with the current standard, and they may or may not add features from the upcoming standard. In addition, they sometimes add their own extensions to the language. So, there's always a portiability risk when compiling C++ code with different compilers. However, recent versions of Visual C++ are fairly close to standards compliant, and most things which compile with it will compile with other popular compilers like gcc/g++ (and vice versa).
VS2008 includes both standard C++ and Microsoft's Managed C++. The standard C++ is mostly compliant with C++03 (at least that was the intent). Managed (i.e non standard) C++ is for developing .NET applications and is not (nor was it intended to be) compliant with any C++ standard.
You might want to make sure that you didn't accidentally select Managed C++ when you ported your app.
Visual C++ is the name of Microsoft's IDE and compiler for the C++ programming language. Note, though, that -- like many C++ implementations -- Visual C++ has certain extensions that are not provided by C++ as well as certain areas where it fails to fully conform to the ISO C++ language standard.
VS C++ is essentially a specific type of C++.
New VS versions include newer functionality, both extensions(such as CLI), and also from newer standards, such as C++0x(type inference, etc.).
Some of that functionality might accidentally cause your code to stop working, or you could be relying on specific Visual Studio bugs that were meanwhile fixed.
Visual C++ contains C++ compiler which is an implementation of C++ Language Standard. Visual C++ 6 is a not conformant implementation. Visual C++ 2008 is much better. There are some changes from VC++6 to VC++2008 that's why your old code could not compile. There're some flags that allows to compile VC++6 code in VC++2008.
Here is a good question already on SO that could be helpful.
I suppose Visual C++ includes Microsoft's library extensions.