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".
Related
I've been looking around to see how I'd accomplish that which is described in the title. That is, I'd like to create a C++ GUI application that:
is portable (no installer)
is cross-platform (Qt solves this)
is open source
works out of the box (i.e. no C++ redistributable installs needed)
I've run into several issues trying to accomplish this. I've narrowed it down to using Qt and NOT using the Visual Studio compiler. Let me explain.
Using Qt would fulfill the cross-platform requirement; it's also highly acclaimed in regard to C++ GUI applications. The issue lies with portability and not having a ton of dependency packages to install before being able to use the application. My goal would be for someone to download a .zip file containing an .exe (and I'd be willing to include other support files e.g. DLLs if necessary) and be able to extract and run that exe out of the box without having to do anything else.
And here's another kicker: as much as I'd like to use Visual Studio (with the Qt Visual Studio Add-in), it just doesn't seem feasible given my requirements. This post covers my issues pretty nicely. Simply put, if I use the Visual Studio compiler, I'd need to either create an installer (no longer a portable app), redistribute some Microsoft DLLs with the app (possible licensing and redist issues here?), or statically link the Visual C++ libraries into the executable (frowned upon technique).
Is there any way to be able to use Visual Studio and fulfill the requirements listed above? Visual Studio is just too fully-featured to pass up. If it's not possible, I think the only other alternatives would be to use a different IDE and/or compiler. For example, I could use QtCreator with MinGW, but then I'd be losing out on some awesome VS debugging features.
My main questions:
Is there any way I can fulfill the requirements above and still use Visual Studio?
Am I wrong about QtCreator not being as fully functional as Visual Studio?
What would be the best way to approach fulfilling my application requirements?
Thanks in advance.
I think your best bet would be to use QT with the MinGW environment. It allows you to create a portable application that supplies runtime DLLs by itself, with added bonus of being completely open source. The QT online installer gives you the option to install the complete MinGW system, and it will work out of the box, not much setup needed.
You could still use Visual Studio for development; there even is a QT plugin for it (I am not sure if VS2015 is supported, but if not that should only take some time).
QTCreator is actually a quite nice IDE, but it cannot stand up to Visual Studio. It is obviously optimized to cater to the needs of QT programmers, but I found that it is quite clunky from time to time. If your project is small it could be a viable choice, but since Visual Studio 2015 Community is basically free I would opt for that. The VS plugin will still use QTCreator's GUI editor though (which is really good)
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)
This maybe a beginner question but could not find proper answer on the internet.
I am curious can I use some other compiler (which I like) in Visual Studio 10?
As of Visual Studio 2010, it is conceptually possible to integrate another compiler. In the book ‘Inside the Microsoft Build Engine, Using MSBuild and Team Foundation Buid’ 2nd edition, on page 338, the chapter ‘Adding a New Platform and Platform Toolset’ the process of adding gcc to visual studio is explained.
However, while it is possible, it has always remained as a concept. To my awareness, nobody has actually been up to the task and publicly disclosed the results. But even with this support, you'd still be lacking debugging facilities. Which would require your compiler of choice to generate .pdb files and/or extend visual studio with a new local debugger
In summary it's quite a venture
You can use other compiler Intel c++ in VS. I don't think any other compiler supports VS.The main reason behind it is lack of plug-ins in VS. But you can use cmake scripts to compile your code in different compilers. With eclipse you can use most of the compilers (VS,gcc). Code blocks also allows you to choose the compilers.
Yes,you can use Intel C++,and even MATLAB 7.1 or later for sure..here is a reference to use MATLABIt gives a step by step procedure to use MATLAB with VS
You can also write Java programs and include javac compiler for it...you can refer this if needed..Including javac with VS
I kno this is surely possible from VS 2010 but not sure for the b4 editions..hope it helps..
I have tried searching on the internet but could not find out the compiler used by Visual Studio for C++ applications.
I wanted to know whether it is freely available & whether it can be used for commercial applications.
Traditionally I have been using Turbo C++.
The problem with Visual Studio C++ Express is that it does not work with some applications.
For example, BRL-CAD which is an open source project works properly with the commercial version but gives some problems for the Express edition.
It seems that there is some problem with MinGW compiler as well.
I am told this by the people running that project.
Visual Studio uses the same compiler for all editions. So, the Express edition uses the same compiler as the Professional edition. There are also no restrictions on producing commercial applications, in either case. There are differences in the advanced features offered by the IDE, but the compilers are the same. So whatever your problems are in getting the project to work, it is nothing to do with the compiler.
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++.