Confused about Microsoft C++ offerings and terminology - c++

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)

Related

Why the standard of naming of C++ functions is not exist?

I write the plugins for AutoCAD. If I write the managed (i.e. .net) plugins, then I can use any Visual Studio version which can work with .NET Framework version which are used by AutoCAD (it is very convenient):
AutoCAD 2009 can use .NET 3.0, 3.5
AutoCAD 2010 can use .NET 3.5.
...
AutoCAD 2016 can use .NET 4.5, 4.5.1
So, through Visual Studio 2013 I can write the .net plugins for AutoCAD 2009-2016.
But sometimes I need to write unmanaged plugins for AutoCAD, because its managed .net API covers unmanaged API (ObjectARX SDK) not complettely. ObjectARX is API for C++. At this case I can't use the same Visual Studio for each AutoCAD version. For example, I am to use VS 2005 for AutoCAD 2009 plugins writting. Therefore I have installed VS 2005-2013 on my virtual machine. It is very unconvenient in my opinion.
I know, this problem exists because the standard of C++ functions naming is not exist and each version of VS has own rules of the name generation for the functions which aren't marked by external "C".
But why this standard is not exist still? What the reason of it? I am sure this reason is exists. Such behaviour is unconvenient is not for me only (I asked other programmers about it). But they don't know why each new VS version has own rules of C++ function naming and why standard of nameing of C++ functions is not exist.
Thank you.
A standard does exist, see https://mentorembedded.github.io/cxx-abi/abi.html#mangling
But not all compilers use it, because they have their own mangling conventions that they have used for many years, and they don't want to change them for various reasons.
In your case the differences between different versions of Visual Studio are not just name mangling, there are changes in the C++ runtime library and the standard library.

Native C++ programs in Visual Studio

I'm confused in my understanding of the relationship between Visual Studio and .NET. I want to write a C++ application, but not a ".NET C++" application. By this, I mean that my understanding is that everything built in .NET land gets compiled to a CLI-compatible intermediary code (just like "JVM" languages like Java and Groovy compile to the same bytecode).
But I don't want my app compiled to an intermediary bytecode...I want it compiled down to raw binary!
Does Visual Studio do this? Or is .NET forced down my throat the minute I choose VS as my C++ IDE? If so, whats a "raw C++" alternative to VS?
Thanks in advance!
Visual Studio is an IDE, which is orthogonal to any specific language or compiler.
Visual C++ is a compiler that supports the C, C++, and C++/CLI languages.
In Visual Studio, create a Visual C++ project from one of the 'Win32' (as opposed to 'CLR') project templates and your program won't have any .NET dependency.
there is that /clr compiler switch when compiling a c++ app. Without it, you will get a pure native binary and cannot use any. NET specific features within your code.
By selecting a project template or by setting the corresponding project property, VS will automatically choose if the switch is on or off.
Visual Studio still supports 100% native C++ applications as will as managed applications. When creating a new app just choose the "Win32 Console Application" to create a native application. For existing applications you can change / verify by doing the following
Right Click on the project and select "Properties"
Navigate to Configuration Properties -> C/C++
Make sure that "Common Language Runtime Support" is set to "No Common Language Runtime Support"

Do I have to use "Visual" C++ in VS 2008?

I am new to Visual Studio 2008 (.NET Framework 3.5) and am Developing a Windows Form application.
Starting the IDE, the only options for a New Project are under the categories:
Visual Basic
Visual C#
Visual C++
I did Visual C++ -> CLR -> Windows Forms Application
However, the template code is in the "Visual C++" syntx.
How do I create a new GUI project with plain vanilla C/C++ using Visual Studio 2008?
Please note, the last time I did this was with MFC in Visual Studio C++ 6.0
If I am missing the underlying principal please explain.
Thank You!
Example: http://msdn.microsoft.com/en-us/library/ms235634%28v=vs.90%29.aspx
Long story short - you cannot.
Windows Forms is a .NET framework and not a C++ framework. This in turn means that you cannot use C++ to work with it. What Microsoft did is invented their own language that is C++-ish, but compiles into CLI bytecode (likely with native code mix-in, but I am not sure). Before it was "Managed C++", now it is C++/CLI (what you have linked as an example is not C++, but C++/CLI).
For plain C++ projects you have to choose "Win32 Project", "Win32 Console Application" or "Empty Project".. But then you cannot work with Windows Forms. Your options would be to use other GUI libraries like GTK, Qt, WxWidgets. There are tons of GUI frameworks. Or perhaps you would prefer sticking with Win32 API. My personal choice is Qt. And no Visual Studio at all.
Hope it clarifies things a bit for you. Good luck!
The "Visual" is just the name of the product. It's not a different language. c++/cli however, is a different language, and that's what you're seeing. If you want to make a Windows Form application, you will have to use .net. C++/cli is a .net language, C++ is not. You can make actual C++ applications with Visual C++, just not Windows Form applications.
First, there is no such thing as "Visual C++", in terms of a language. There is C++/CLI, which is a sort of variation of C++ that has extensions for building .NET libraries and programs using a C++-like language.
Windows Forms is a technology based on the CLR: common language runtime. AKA: .NET. You cannot build a Windows Forms application with just ISO C++. At some point, you have to talk to the CLR, which is at minimum going to require some COM support. And you'd probably be better off with C++/CLI and doing it that way.
Visual in this case means Windows Programming. And that include designing GUI (Graphical User Interface) for your application which will work in Windows environment. The language itself is C++.
You have two options available to develop Window Application.
Use Window API's only
Use a frame such as MFC,WPF etc
The language is always C++ but it has accommodation for Windows and therefore Visual C++.
Btw if you want plain C/C++, choose Visual C++ and start a console application. Make sure you select empty project.

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++.