What is the difference between Visual C++ and C++? - c++

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.

Related

Confused about Microsoft C++ offerings and terminology

I'm using C++ for the first time since pre-.Net days and I'm confused about some of their C++ offerings and how they name them.
Prior to .Net, Microsoft supported a language called C++ which was pretty close to the industry standard. But when they introduced .Net they add a lot of extensions to their C++ and called it "Managed C++".
Then in 2005 they dropped that and replaced in with "C++/CLI" which is a version of C++ that conforms to Microsoft's (ISO-certified) Common Language Infrastructure and has some syntax changes (e.g., ^ instead of * for pointing to .Net objects, etc). C++/CLI can be compiled down to the platform-neutral Common Intermediate Language (CIL). At runtime this is processed into machine code by the Common Language Runtime (CLR). Here's a diagram from Wikipedia:
http://en.wikipedia.org/wiki/File:Overview_of_the_Common_Language_Infrastructure.svg
Here's where I get confused:
In Visual Studio 2010 Professional I don't see the term "C++/CLI" anywhere, even though that is supposedly what Microsoft is offering. If I do File->New->Project->Other Languages it lets me select "Visual C++"
1. What is "Visual C++" and how does it relate to C++/CLI?
At the top level of "Visual C++" it lets me create an "Empty Project" and in the Project Properties for it, Common Language Runtime is set to "No Common Language Runtime Support"
2. Does "No Common Language Runtime Support" also mean no CLI/CIL and thus no C++/CLI syntax? In other words does the state of that setting determine whether this is "C++/CLI" or just plain old unmanaged C++?
Underneath "Visual C++" it also has entries for CLR and General. If I make a CLR Empty project I notice that Common Language Runtime is set to "Common Language Runtime Support /clr"
3. Is that the only difference between a Visual C++ empty project and a Visual C++ CLR empty project?
4. What is a Visual C++ "General" empty project?
5. Is all this stuff documented/explained somewhere?
EDIT: Since posting my question I've noticed that it's even more complicated. The default properties for Common Language Runtime vary on different templates under the CLR node from CLR to CLR with "Pure" MSIL to CLR with "Safe" MSIL. And that's just that one "Common Language Runtime" setting. Does Microsoft document these templates anyplace?
The Wikipedia article on Microsoft Visual Studio says:
Microsoft Visual C++ is Microsoft's implementation of the C and C++
compiler and associated languages-services and specific tools for
integration with the Visual Studio IDE. It can compile either in C
mode or C++ mode. For C, it follows the ISO C standard with parts of
C99 specification along with MS-specific additions in the form of
libraries. For C++, it follows the ANSI C++ specification along with
a few C++11 features. It also supports the C++/CLI specification to
write managed code, as well as mixed-mode code (a mix of native and
managed code). Microsoft positions Visual C++ for development in
native code or in code that contains both native as well as managed
components. Visual C++ supports COM as well as the MFC library. For
MFC development, it provides a set of wizards for creating and
customizing MFC boilerplate code, and creating GUI applications using
MFC. Visual C++ can also use the Visual Studio forms designer to
design UI graphically. Visual C++ can also be used with the Windows
API. It also supports the use of intrinsic functions, which are
functions recognized by the compiler itself and not implemented as a
library. Intrinsic functions are used to expose the SSE instruction
set of modern CPUs. Visual C++ also includes the OpenMP (version 2.0)
specification.
So, I can have a go at answering your questions (which, by the way, are too broad):
Microsoft Visual C++ (often abbreviated as MSVC or VC++) is a commercial (free version available), integrated development environment (IDE) product from Microsoft for the C, C++, and C++/CLI programming languages. It features tools for developing and debugging C++ code, especially code written for the Microsoft Windows API, the DirectX API, and the Microsoft .NET Framework.
I'd say yes.
I'd say yes, but that is a big difference in itself, even if it is the only one.
I don't know exactly. I guess an empty project is a project which is designed so that you add your own stuff to it. "General" probably means that the project is not of any specific kind.
Microsoft has tons of documentation on MSDN, but has a long tradition in confusing people between the real C++ and their own managed C++-ish language, whatever they call it today. (I have always thought that this is bad, because C++ is C++ and there are lots of names out there for your new language, and that they've done it on purpose to gain clueless users. But this last sentence is an opinion, so it doesn't belong here. Hence the brackets.)
Does "No Common Language Runtime Support" also mean no CLI/CIL and thus no C++/CLI syntax? In other words does the state of that setting
determine whether this is "C++/CLI" or just plain old unmanaged C++?
Yes it means.
When you select "Create a new project" you can select (something as) "CLR Console Application" It means C++/CLI console application.
Also you can create Managed C++ console application if in the project properties you select option as
(something as) "CLR-support, old syntax (/clr:oldSyntax)" (I have Russian edition of MS VS 2010)

Can I set the Visual Studio compiler to conform to a specific version of c++?

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.

Which version of C++ am I using?

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.

Using a pure C++ compiler versus Visual C++

I searched around for the answers to these questions, but I have had little luck. So, I thought I would post them here to get some clarification. If this is a duplicate, please let me know, and I will close this.
Okay, with that said, I would like to begin learning C++. I come from a C# background and I have a great respect for Visual Studio and what it can do. Now, my question is. How well does Visual Studio's compiler work for C++ as opposed to a non-Microsoft version (such as MinGW)?
My thing is this. I have nothing wrong with Microsoft, but I would really like to learn C++ in a "pure" form and not scewed by any particular implementation. How reliant is Visual C++ on the .NET Framework? Can a "pure" C++ application be created through Visual Studio without any .NET usage or overhead? Does the Visual Studio compiler compile C++ into CIL like it does with C#/VB, or does it compile it all the way down as others do?
Thanks for any help anyone can provide!
The Visual C++ compiler will compile C++ code into standalone EXEs that have nothing to do with the .NET framework.
The only way to get the .NET baggage thrown in is to compile the C++ as "managed".
If you create a new project (File|New|New Project) Then choose "Win32" from the Visual C++ submenu in the project types and choose "Win32 Console Application" Visual studio will create a simple project with a couple of source files that will compile to a little executable.
Most of the time, Visual C++ is very similar to other compilers. Avoid #pragmas, microsoft libraries (MFC, ATL) and you should be fine.
Edit (thanks Cheeso) - Documentation of where Visual C++ diverges from standard.
In general I would advise using boost libraries for threads and networking because they work on many platforms (i.e linux). Also if your code can compile in GCC and Visual Studio then you are doing a good job keeping it portable.
The most recent versions of VC++ have become significantly more compliant to the C++ standard, so it's not really an issue to write "pure" C++ using Visual Studio, presuming that you stay out of the Windows API, COM+ and ATL. In fact, the documentation with Visual Studio is very rich, with details on the standard libraries and the STL, so it can help you learn a great deal. It can't teach you everything, but it's certainly loaded up with a wealth of information that is portable to any compiler and it is very easily accessbible inside the IDE.
If you create a new solution you should choose new Win32 Project, or Win32 Console Application, and check the 'Empty Project' option. Then you can add a main.cpp file, and add your standard C++ code.
If you like Visual Studio, go ahead and use it to learn C++ -- I haven't used the very latest version, but even the previous one was pretty standards-compliant, C++-wise, and I assume the latest one can only have gotten better. You can have many different kinds of project in Visual Studio, including "console apps", which are the "plain vanilla" kind you could make on any platform, and also many other kinds, such as, windows apps using the good old win32 api, ones made with MFC or other frameworks older than .NET, .NET ones using "managed code", etc.
Just make sure you always work in a "console app" project, and you'll be operating pretty closely to how you would be on other platforms and/or with other C++ IDEs.
If you limit yourself to writing ANSI C++ compliant code then what you write in VS will work in other compilers, until you have to interact with a graphic interface or IO. Then you need to make certain that you are using something that is portable, such as OpenGL, and not DirectX.
To set your project the steps here may be useful:
http://bytes.com/topic/net/answers/447572-strict-ansi-c
Microsoft Visual Studio 2005 comes with a very good, C++98 standard compliant pure C++ compiler. If you are interested in pure C++, don't forget to disable language extensions in project settings and you are good to go. Nobody is going to force you to use .NET framework, MFC or anyting like that. Just pure core C++ language and C++ standard library.
Of course, just like any other compiler, it has known non-compliance issues, but in general it is, again, surprisingly good. Older versions of their compiler (MS VS 6.0 specifically) suffered from many non-compliance problems and could not even compile its own header files with language extensions disabled. In 2005 version they fixed a lot of these issues.
After creating a standard Win32 project, you can turn up the compliance a bit more. On the project properties sheet, there's a C/C++ category, with a Language entry. This lists a number of cases where VC++ can differ from the standard. Here, you'd want to turn OFF language extensions, and turn ON "wchar_t as built-in type", "for-loop conformance" and "RTTI support".

What is the difference between "VC++" and "C++"?

Someone asked me how familiar I am with VC++ and how familiar I am with C++. What is the difference?
C++ is the actual language, VC++ is Microsoft's Visual C++, an IDE for C++ development.
From stason.org:
C++ is the programming language, Visual C++ is Microsoft's implementation of it.
When people talk about learning Visual C++, it usually has more to do with learning how to use the programming environment, and how to use the Microsoft Foundation Classes (MFCs) for Windows rather than any language issues. Visual C++ can and will compile straight C and C++.
C++ is the name of a programming language that has been approved by international standards committees (ANSI/ISO).
VC++ (“Visual C++”) is the product name of Microsoft's C++ compiler and sometimes, but not officially, the IDE it's shipped with (“Visual Studio”).
Well, Visual C++ used to stand for the Microsoft C++ compiler plus the MFC library. Basically there's no difference in the language itself, but VC++ includes a library, and some IDE support, for easily building GUIs.
vc++ is a development environment and c++ is a language
VC++ means different things to different people. You can use the Visual Studio environment to build (almost) standard C++ applications. You can also use it for Micrososft-specific additions - which vary from version to version. For example, the MFC components for windows applications, or the newer C++/CLI for .NET applications
VC++ is short for Visual C++, and is an IDE (integrated development environment) developed by Microsoft, included as part of Visual Studio. C++ is a language.
C++ is a language, VC++ (Visual C++) is a Microsoft development environment which was a forerunner to Visual Studio which helps you write C++.
You can know everything there is to know about C++ and never have seen VC++.
VC++ is IDE developed by Microsoft using microsoft c++ compiler.while C++ is the programming language.
Visual C++ and C++ are two entirely different things. They are related, though.
C++ is a high-level programming language that a compiler translates into machine code a computer can understand and execute.
Visual C++ is a tool created by Microsoft to make writing, compiling and debugging C++ source code easier. Visual C++ is an Integrated Development Environment (IDE).
http://www.cplusplus.com/forum/beginner/172353/
In some cases, they refer to its corresponding C++ implementation and its compilers.
C++ refers to standard headers/functions and its GCC C++ compiler.
VC++ refers to Microsoft implementation of C++ standard and its VC++
compiler.
They are not compatible with each other. Linux network/threading functions, numeric data types are different than its Windows counterpart. You can't compile Linux C++ code directly in Windows without using third-party GCC ports such as Cygwin/MinGW.
Most academic/research tools and libraries are written in C++ (GCC), and one will have the hard time to compile those in VC++.