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

I was looking for answers to these questions, but I had no luck. So, I thought I'd post them here to get clarification. If this is a duplicate, let me know and I will close it.

Well, with that said, I would like to start learning C ++. I come from C # and I really respect Visual Studio and what it can do. Now, my question. How well does the Visual Studio compiler for C ++ work, as opposed to a version other than Microsoft (e.g. MinGW)?

My point is this. I have nothing wrong with Microsoft, but I would really like to learn C ++ in a "clean" form and not use any specific implementation. How reliant is Visual C ++ in the .NET Framework? Is it possible to create a “clean” C ++ application using Visual Studio without using .NET or overhead? Does the Visual Studio compiler compile C ++ to CIL, as it does with C # / VB, or does it compile it to the end, like others do?

Thanks for any help anyone can provide!

+6
c ++ compiler-construction visual-c ++ ide
source share
7 answers

The Visual C ++ Compiler compiles C ++ code into stand-alone EXEs that have nothing to do with the .NET platform.

The only way to get loaded .NET baggage is to compile C ++ as “managed”.

If you are creating a new project (File | New | New Project), then select "Win32" from the Visual C ++ submenu in the project types and select "Win32 Console Application". Visual studio will create a simple project with multiple source files that will be compiled for a small executable file.

In most cases, Visual C ++ is very similar to other compilers. Avoid #pragmas, microsoft libraries (MFC, ATL) and you should be fine.

Edit (thanks to Cheeso) - Documentation on where Visual C ++ diverges from the standard .

In general, I would recommend using boost libraries for streams and networks, because they work on many platforms (for example, Linux). Also, if your code can be compiled in GCC and Visual Studio, then you are doing the migration well.

+20
source share

The most recent versions of VC ++ have become significantly more compatible with the C ++ standard, so it’s really not a problem to write “clean” C ++ using Visual Studio, assuming that you remain outside the Windows API, COM +, and ATL. In fact, the documentation with Visual Studio is very rich, with detailed information on standard libraries and STL, so it can help you learn a lot. He cannot teach you everything, but he is surely loaded with a huge amount of information that is portable to any compiler, and it is very easily accessible in the IDE.

+6
source share

If you are creating a new solution, you must select the new Win32 Project or Win32 Console Application and check the "Empty Project" option. Then you can add the main.cpp file and add your standard C ++ code.

+3
source share

If you like Visual Studio, use it to learn C ++ - I did not use the latest version, but even the previous one was pretty standards compliant, C ++ is wise, and I guess the latter can only improve. You can have many different projects in Visual Studio, including “console applications” that are “plain vanilla” that you could create on any platform, as well as many other kinds, such as Windows applications, using the good old win32 api made with MFC or other platforms older than .NET, .NET using "managed code", etc.

Just make sure that you always work in the console application project and you will work very close to how you will be on other platforms and / or with other C ++ IDEs.

+3
source share

If you limit yourself to writing ANSI C ++ compatible code, then what you write in VS will work in other compilers until you have to interact with the GUI or IO. Then you need to make sure that you are using something portable like OpenGL, not DirectX.

To set up a project, the following steps may be useful here: http://bytes.com/topic/net/answers/447572-strict-ansi-c

+2
source share

Microsoft Visual Studio 2005 comes with a very good C ++ 98 compatible clean C ++ compiler. If you are interested in pure C ++, do not forget to disable language extensions in the project settings, and you are good to go. No one will force you to use the .NET framework, MFC, or something like that. Just pure C ++ core language and C ++ standard library.

Of course, like any other compiler, he knew problems with non-compliance, but in general this, again, is surprisingly good. Older versions of their compiler (MS VS 6.0 specifically) suffered from many problems related to non-compliance, and could not even compile their own header files with language extensions disabled. In the 2005 version, they fixed many of these problems.

+2
source share

After creating a standard Win32 project, you can increase compliance a bit more. On the project properties page there is a C / C ++ category with a language entry. This lists cases where VC ++ may differ from the standard. Here you want to disable language extensions and enable "wchar_t as a built-in type", "match for loop" and "RTTI support".

+1
source share

All Articles