Difference between different compliers for c++

Feb 3, 2012 at 6:26am
Hey, i have been writing most of my programs on Dev-c++, but i recently installed code blocks, and it shows me a list of compilers that it supports, so it made me wonder, what is the difference between all these compilers such as GCC, borland compiler and Visual c++ compiler. ????
Feb 3, 2012 at 10:54am
as far as I understand, different compilers have different C++ syntax.
For example in Borland void main(){} is valid while in Dev-C++ main must return int.
I just use the first compiler on the list (which is GCC I think).
I don't like Borland and I have never tried Visual C++.
Feb 3, 2012 at 11:19am
The C++ language is defined in a paper document.

A compiler writer then takes that paper document and writes a program that will turn text conforming to the document (i.e. C++ source code) into something that will make a given processor (for example, an x86 processor) do what the paper document said should happen.

The differences between compilers are differences in how the writer decided to implement each part of the paper document's instructions, and the hardware that the output is designed to run on.

A compiler that accepts void main(){} does not conform to the paper document (the C++ language definition). A good compiler does conform. Many compilers have "extensions" - extra things they will understand and compile that are not in the C++ standard. Some compilers produce output that is less efficient than others. Some compilers are missing features of the C++ language. There is no one true C++ compiler - only interpretations and attempts at meeting the C++ language.
Feb 3, 2012 at 3:31pm
So which of the compilers is the best then? I noticed earlier (and I erred a lot in a different thread on this) that GCC doesn't allow void main while some elses compiler did. So what sets the standard for a good compiler?
Feb 3, 2012 at 3:37pm
So which of the compilers is the best then?


A lot of modern compilers all do a pretty good job of meeting the standard (the C++ 98 standard, that is; the C++ 11 standard is still being met - https://wiki.apache.org/stdcxx/C%2B%2B0xCompilerSupport and http://www.aristeia.com/C++11/C++11FeatureAvailability.htm).

After that, it becomes personal preference and things such as using the same tools as other team-members, ease of use and all the other such things. There is no "one best compiler", although there are definitely bad options (Dev-Cpp, for example, uses a decade old version of gcc).
Feb 3, 2012 at 6:31pm
Visual Studio's C++ part has pretty nice debugging tools, but they support only a very limited subset of C++11 and they are extending their support so slowly that it's going to take years until they've covered ever just the most important features. (I imagine the reason being that MS simply doesn't care that much about C++ and instead hopes that most people will use .NET for windows development - a notion I can't completely disagree with though).

g++ is much more actively maintained, and I personally prefer using it. I don't know much about other compilers though.
Feb 3, 2012 at 7:43pm
Visual Studio's C++ part has pretty nice debugging tools, but they support only a very limited subset of C++11 and they are extending their support so slowly that it's going to take years until they've covered ever just the most important features.

For example VS has support for <regex> header since VS 2008 SP1, GCC does NOT support this yet. (you will get linker errors, implementation is missing) I use regular expression frequently in my applications.

This is just an example from my experience.
Feb 3, 2012 at 7:48pm
Another example, Visual Studio 2010 supports the C++11 locale-independent Unicode conversion library <codecvt>, which GCC does not, not even in the latest 4.7 builds from 2012. (the other cutting edge compiler, Clang++, has been supporting codecvt for a while now).

There's no clear winner today (although if pressed, I'd say clang++), as far as the race to support most of C++11 goes.
Last edited on Feb 3, 2012 at 7:49pm
Feb 3, 2012 at 8:39pm
I don't know what gcc you're using, but mine has C++11 regex (at least it did last time I checked). Though honestly, unless I only have to check for something really, really simple I prefer not to use regex's cause they are a giant mess to read and write.
Topic archived. No new replies allowed.