Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 549
darthnosaj Avatar asked Oct 16 '09 00:10

darthnosaj


People also ask

What is the difference between Visual C and C?

Key Differences Between C++ and Visual C++C++ is an object-oriented programming language, whereas Visual C++ is the Integrated Development Environment (IDE) and compiler for C and C++ language. In C++, a compiler translates the C++ program code into machine code which computers can understand and execute the same.

Should I use Visual Studio for C?

Yes, you very well can learn C using Visual Studio. Visual Studio comes with its own C compiler, which is actually the C++ compiler. Just use the . c file extension to save your source code.

What compiler should I use for C?

The compiler that we recommend is the GNU Compiler collection or GCC. This is a widely used cross-platform compiler toolsuite that has libraries and compilers for C, C++, Fortran, Java, and more. Additionally the compiler that we will use later on in the course for compiling C code to run on the PIC32 is based on GCC.

What is the most used compiler for C?

GNU C Compiler or GCC is the most popular and most widely used among the developers who use C as their programming language. GCC is an open-source compiler and comes free with all flavors of Linux and Unix distributions. GCC is also available in Macintosh computers running Mac OS X.


4 Answers

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.

like image 50
Tom Leys Avatar answered Oct 21 '22 01:10

Tom Leys


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.

like image 34
Joanne C Avatar answered Oct 21 '22 00:10

Joanne C


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.

like image 21
StackedCrooked Avatar answered Oct 20 '22 23:10

StackedCrooked


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.

like image 45
Alex Martelli Avatar answered Oct 21 '22 01:10

Alex Martelli