Page 1 of 1

Best C/C++ compiler

Posted: Tue Sep 11, 2007 1:27 pm
by Zacariaz
Ive desided not to make a vote as i probably dont know half of those in existence.
A few rules though, OS independency, meaning that the compiler have to be avalible for for at least windows and linux. Also it has got to be freeware, opensource, whatever...
Free it has got to be!

A short discribition including pros and cons and stuff would allso be nice.


Regards

Posted: Tue Sep 11, 2007 1:42 pm
by Candy
Few hints about possible winners:

GCC for obvious reasons

ICC (Intel C++ Compiler) - Fast, windows + linux, good code generation, free to use for non-commercial (and possibly also commercial) but not open source

Metrowerks Codewarrior - No clue, just well-known for being pretty good

Comeau C++ - Not all that known but the first C++ compiler to support export, so it must have its merits.


My vote is for GCC because of ubiquity, ease of use, clear error messages (apart from templates - but that's being worked on in the language and the others are even worse) and speed. It's also very good at guessing what I'm trying to do instead of what I type so at times I type some 100 lines of code and it optimizes my handy syntactic sugar to 4 lines of assembly.

Posted: Tue Sep 11, 2007 2:07 pm
by Brynet-Inc
I can name a few that I know... but haven't used for OSDev..

The following should be are Open Source.. or at least have source available..
http://fabrice.bellard.free.fr/tcc/ - Tiny C Compiler - Open Source/Portable.
http://www.cs.princeton.edu/software/lcc/ - LCC - A Retargetable Compiler for ANSI C.
http://tack.sourceforge.net/ - The Amsterdam Compiler Kit - It's based off of the BSD licenced Minix C compiler.
http://www.tendra.org/ - BSD licenced C/C++ compiler... neat project..
http://nwcc.sourceforge.net/ - Nils Weller's C compiler - Another BSD licenced C compiler...
http://www.cpm.z80.de/small_c.html - Small C - It's a common C compiler... It's old though..
http://retro.tunes.org/simplec/ - Simple C - Port of Small C for Linux..

I'm sure you could find a few other smaller projects, The big one your already know about ;).. http://gcc.gnu.org/

The many proprietary/freeware compilers shall remain nameless :D

Posted: Tue Sep 11, 2007 2:32 pm
by Combuster
I think it depends on where you ask - the majority here uses GCC for it suiting the purposes of OS development. If you'd ask a regular windows programmer, you'd probably hear Visual C as being the best compiler. (not that it qualifies for the purposes here.)

If you ask at the right place ICC may very well be the most likely answer.

Of the compilers I have tried that meet the criteria, nwcc didn't compile under cygwin, leaving GCC as the only alternative. (I did try installing lcc once, but since that box had less than 30 mb free that obviously didn't work out)

Posted: Tue Sep 11, 2007 2:53 pm
by elderK
Does the Intel compiler have any serious advantages over GCC?

~Z

Posted: Tue Sep 11, 2007 2:56 pm
by Candy
Combuster wrote:I think it depends on where you ask - the majority here uses GCC for it suiting the purposes of OS development. If you'd ask a regular windows programmer, you'd probably hear Visual C as being the best compiler. (not that it qualifies for the purposes here.)
C++ programmers that use the language rarely answer Visual C++ as their preferred compiler as it contains a number of flaws and errors that make using C++ with it harder than is necessary. I haven't used the bottom of the options in C++ and I've been hit by a compiler bug in VS2005 already, so it aren't even just the unlikeliest cases.

Posted: Tue Sep 11, 2007 3:05 pm
by Brynet-Inc
I found another compiler, I'm not sure about licencing.. but the source is available.. supports many processor architectures.

http://www.compilers.de/vbcc.html - vbcc - portable ISO C compiler..

I'm done searching, but I though it was worth trying to index a few of them 8)

Posted: Wed Sep 12, 2007 2:07 am
by Solar
zeii wrote:Does the Intel compiler have any serious advantages over GCC?
Last time I looked, ICC generated much more efficient code than GCC (~20% better). However, that has been quite some time since, and GCC 3.x. AFAIK, one of the goals of GCC 4.x was to rectify this, I don't know how successful they were.

Oh, and I'd like to stress that the EDG / Cameau compiler is the only fully compliant C++ compiler available. Funny thing: The EDG was adamant in their resistance against including "export" in the C++ standard, yet still they're the only ones that implemented it in their compiler...

Posted: Wed Sep 12, 2007 8:37 pm
by niteice
ICC generates better code, but some very fine-tuning of optimizations cause it to (automatically) fail on non-Intel processors. 90% of code will probably never reach that point, though.

Also, ICC reportedly uses the EDG frontend, so it may be the second fully compliant C++ compiler. :D

Posted: Thu Sep 20, 2007 6:15 pm
by kataklinger
1. Intel C++
2. MSFT VC++ (7.0+)
3. all others
ICC generates better code, but some very fine-tuning of optimizations cause it to (automatically) fail on non-Intel processors. 90% of code will probably never reach that point, though.
I read somewhere (and saw tests) that in fact ICC generated code is executed faster on AMD's processors then code generated by other compliers in most cases.

Posted: Fri Sep 21, 2007 8:46 pm
by niteice
I'm not surprised. However, what I was referring to was a small processor check at program startup that automatically terminates if the machine doesn't have at least a specific model of Intel processor (generally a feature set such as SSE3).

Posted: Fri Sep 21, 2007 9:23 pm
by Brynet-Inc
niteice wrote:I'm not surprised. However, what I was referring to was a small processor check at program startup that automatically terminates if the machine doesn't have at least a specific model of Intel processor (generally a feature set such as SSE3).
I remember reading that Intel's C/C++ compiler generates code that deliberately "favours" Intel Processors..

http://www.swallowtail.org/naughty-intel.html

According to that article it was eventually "fixed" in newer versions... but it's still interesting...

I'll stick with GCC ;).. hopefully the BSD licenced C compiler that was imported into OpenBSD improves as well 8)

Posted: Sun Sep 23, 2007 9:29 pm
by dengll23
I only have used the Visual C++... :cry: