0

Does Visual Studio produce only C++/CLI? I was told to avoid C++/CLI and the Microsoft compiler like plague.

I'd like to learn how to program platform independent software, so what 'true C++' compiler would you recommend? (Since from what I've gathered so far it seems that C++/CLI would bind me to Windows with it's dependence on some Windows libraries)

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Pavel Matuska
  • 776
  • 9
  • 24
  • 4
    no idea why someone told you to avoid the MS compiler *like the plague* but it was bad advice. Apart from that, it does compile standard C++, cli is seperate and has to be turned on using options. – stijn Jan 07 '12 at 19:19

4 Answers4

4

Does Visual Studio produce only C++/CLI?

No, the Visual C++ compiler supports ISO C++03 (with a handful of conformance issues) and many C++11 features. It also supports C++/CLI and (in the upcoming version) C++/CX, but there is no requirement that you use either of those language extensions.

I'd like to learn how to program platform independent software, so what 'true C++' compiler would you recommend?

The best way to ensure that your C++ code is not relying on the features of one particular compiler is to compile it with multiple compilers.

James McNellis
  • 348,265
  • 75
  • 913
  • 977
  • Since you mention specific versions of C++, it would be nice if you mentioned which version VS are you talking about too. – svick Jan 07 '12 at 19:39
  • @svick: James's comments reflect the VC++ compiler included with Visual Studio 2005, 2008, 2010, service packs thereto, and versions of the Platform SDK/Windows SDK for Vista and later. A technical preview of the "upcoming version" mentioned is part of the Win8 developer preview. – Ben Voigt Jan 08 '12 at 16:06
2

Visual Studio is able to compile unmanaged C++ as well as C++/CLI (managed C++). Each platform you plan to support will have its preferred compiler however gcc is supported by most (including Windows using MinGW or Cygwin).

M.Babcock
  • 18,753
  • 6
  • 54
  • 84
1

First of all, the VC++ compiler doesn't produce C++/CLI at all. C++/CLI is a textual language describing your program, not compiler output.

With the /clr option is used, it accepts either standard C++ or C++/CLI and produces .NET MSIL code (either "pure" MSIL or mixed-mode assemblies) out. When /clr isn't used, it accepts only standard C++ (with a few Microsoft extensions, mostly related to support for the C++11 draft and some of which are not compatible with the C++11 final standard) and produces native code.

The only thing that "produces" C++/CLI code would be the Visual Studio new project wizard and WinForms designer, and only if you select to create a C++/CLI project. There are new project templates for native code and native dialog editor provided also. And none of these wizards are part of the VC++ compiler.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
0

No, Visual Studio can be pretty much a 'true' c++ compiler.

I'd like to learn how to program platform independent software

Good luck! If you figure out how let us all know!

Joking aside...

If you want your code to be platform independent then you should indeed steer clear of platform specific libraries (like the win32 api).

As stated in other answers VC++ doesn't conform exactly to the C++ specification (not sure if any compiler conforms 100%).

Using GCC on windows (eg mingw, cygwin) may give you an easier time when later you come to port your code to a different platform. Try VC++ and MinGW and see which you prefer. Using them each is different from the other. If you want an IDE for MinGW try Code::Blocks.

In a complex enough project though it becomes very hard to write code that will work with many different c++ compilers, and even with different versions of the same compiler! If you ever look at boost (a c++ project full of wonderful but sometimes complex libraries) which is meant to work on a very wide variety of compilers, it seems that it has more code to deal with differences in compilers than code that actually gets stuff done (slight exaggeration perhaps).

This question: How to write portable code in c++? has some good tips.

Community
  • 1
  • 1
DaedalusFall
  • 8,335
  • 6
  • 30
  • 43