Difference between different compliers for c++

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. ????
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++.
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.
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?
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).
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.
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.
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
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.