tags:

views:

510

answers:

7

What pointers do you use to compare between compilers?

I'm told gcc is the best C compiler, is this true? If so, why?

I mean this generally, so you can state which compiler is more appropriate for which architecture.

(I hear igc would be more appropriate for Intel for instance, but I don't know why)

Personally I intend to use AMD 64 bit, develop both in Linux and Windows, GUI and non GUI apps.

+1  A: 

I know that the INTEL and MS compilers have started doing code generation for SSE3/4 instructions and doing clever things like unfolding loops and supporting vectorisation in the compiler. Not sure GCC does this yet.

Tony Lambert
GCC 4 does if you tell it to.
David Holm
+10  A: 

In general: first of all, the most important aspect of compiler quality is correctness. A compiler with bugs or unexpected behaviour can really wreck your day. The quality of the resulting code, like speed, size and memory usage, is also at the top of the list.

The speed of compilation is another aspect, especially when compiling large projects.

One thing I find particularly important is error handling, the quality of messages you get when the compiler encounters stuff it can't (or won't) handle.

Rik
+8  A: 

Um, dunno where you heard that gcc is the "best C compiler". It's simply the most ubiquitous and also a lot better than the native C compilers provided by most commercial UNIX vendors when gcc came about in the 1990s.

But what defines the "best"?

  • Time to compile code;
  • Size of compiled code;
  • Speed of compiled code;
  • Memory usage of compiled code;
  • Bugs and probability of seg faulting;
  • Support;
  • Community;
  • etc.

Different things matter to different people.

Here's one set of metrics comparing gcc to Intel's compiler and another comparison with clang. I'm sure you can find some comparisons to Microsoft's compiler too.

Generally speaking, people aren't all that concerned with the relateive size or speed or a compiler (or even necessarily with the size or speed of the output less than a factor of two) but whether it works or not (this was a real issue a decade or two ago), whether it supports the relevant standards and whether it has any oddities/bugs/features you have to workaround.

cletus
A: 

Do you mean

  • best by speed of compiling
  • best by smalest code
  • best by fastest code?

You can create a test app, probably with some nasty code (that needs an intelligent optimizer) and use all compilers to test it.

Compare your benchmarks and use the one you like the most.

Gamecat
+1  A: 

I always thought that error messages and warnings make a difference. Some compilers will make it unnecessarily difficult for you to understand what they are trying to say. Others are way more user-friendly. It's also nice when you can enable warnings without the compiler warning you endlessly about stuff it created itself.

innaM
A: 

Correctness is the sine qua non.

I also like

  • To have a compiler that runs really fast (like lcc or ocamlc)
  • To have a compiler that produces really good code (like ocamlopt or MLton)

It's OK if they are two different compilers.

I hate having a compiler that makes programs break when a new version comes out. (Richard Stallman, phone your office.)

Norman Ramsey
A: 

gcc is a horrible compiler. It has the BEST tech support perhaps because of its price, the number of users and the internet (and google for finding that help). But its output is average to below average at best as far as the quality of the machine code it generates.

dwelch