12

I wanted to know what is the current standard C compiler being used by companies. I know of the following compilers and don't understand which one to use for learning purposes.

  1. Turbo C
  2. Borland C
  3. GCC
  4. DJGPP

I am learning C right now and referring to the K&R book.

Can anyone please guide me to which compiler to use?

Psychonaut
  • 859
  • 8
  • 22
name_masked
  • 9,544
  • 41
  • 118
  • 172
  • 6
    GCC all the way... fastest, most used, and best supported compiler. – Rafe Kettler Nov 09 '10 at 00:24
  • 4
    Remember that gcc, by default, is not a conformant compiler. You may want to have a look at its manual and check the many options available. `gcc -std=c99 -pedantic -Wall -Wextra` provides a reasonable invocation :-) – pmg Nov 09 '10 at 00:31
  • 3
    what about [clang](http://clang.llvm.org/)? – Mark Elliot Nov 09 '10 at 00:33
  • @pmg: `-Wwrite-strings` (a.k.a "fix the stupid standard") is next on my priority list after `-Wall -Wextra`. And `-O1` is a useful warning flag, in the sense that without it `-Wuninitialized`, which is part of `-Wextra`, does nothing. – Steve Jessop Nov 09 '10 at 00:39
  • @Steve: my gcc (4.4.5) with `-Wextra` warns about uninitialized variables with or without optimization flags (`-O1`) – pmg Nov 09 '10 at 00:56
  • 1
    `-Wall` and `-Wextra` warn about plenty of things which are purely style opinions of the developers and not incorrect usage of C. Coming up with a sane set of warning flags for gcc is not easy. – R.. GitHub STOP HELPING ICE Nov 09 '10 at 01:02
  • @pmg: that's good. I'm not using the current standard compiler, just whatever cygwin gives me. Or rather, whatever it gave me last time I bothered updating. – Steve Jessop Nov 09 '10 at 01:02
  • 1
    There is no one standard compiler. Each different environment is liable to have its own most popular compiler, but even so most will have multiple compilers. Finally, most compiler-specific issues are relatively minor, but it is handy to have multiple compilers to test against at the same time. Just find a couple for your platform. – wnoise Nov 09 '10 at 01:19
  • @pmg I'd remove the pedantic flag unless you absolutely need it. Pedantic C can cause some headaches when first learning C. – LandonSchropp Nov 09 '10 at 02:07
  • 1
    @helixed: but that's the point: learn standard C. If you want to learn "GNU-C: almost C, but not quite" or some other dialect of C, then don't try to invoke your compiler as a C compiler – pmg Nov 09 '10 at 07:58
  • @Steve: using `volatile` makes my gcc behave as you describe --- see [here](http://pastehtml.com/view/1bulauc.html) – pmg Nov 09 '10 at 18:59
  • @pmg: interesting. `volatile` must affect the DFA somehow. – Steve Jessop Nov 09 '10 at 21:45
  • @pmg Whoops, I was confusing -pedantic with -ansi. You're right, my bad. – LandonSchropp Nov 10 '10 at 07:33

8 Answers8

20

GCC would be the standard, best supported and fastest open source compiler used by most (sane) people.

Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
  • 10
    Wow that is a bit much. Intel's compiler has been 20-30% faster than GCC for as long as I can remember, and so far as I know nothing has changed recently. – stonemetal Nov 09 '10 at 00:47
  • 2
    Corporations usually standardise on the compiler supplied with the OS. VS C++ for windows, gcc for linux, the compiler supplied by Oracle, IBM or HP for other unixes. – James Anderson Nov 09 '10 at 02:40
  • 1
    @stonemetal I believe its mostly for Intel CPU, it will suffer slowdowns for AMD CPU's. – Pharaun Nov 09 '10 at 14:32
15

GCC is going to have the best support of the choices you've listed for the simple reason that it comes standard in GNU and is the target of Linux. It's very unlikely any organization would use the other three beyond possibly supporting some horrible legacy application.

Other C compilers you might look into include:

chrisaycock
  • 36,470
  • 14
  • 88
  • 125
  • 3
    +1 I also like tcc ( http://bellard.org/tcc/ ), the "Tiny C Compiler"; especially for treating quick snippets as scripts ( `tcc -run snippet.c` ) – pmg Nov 09 '10 at 01:13
7

If you are starting to learn the language, Clang's much better diagnostics will help you.

To make your (job) applications tools section look better, GCC (and maybe Visual Studio) are good to have knowledge of.

Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
  • Yes, clang is very good at diagnostics. But I take it from the list of compilers that the writer is running on a Windows platform. How easy is it to set up clang on Windows? – onemasse Nov 09 '10 at 13:13
2

GCC (which I use in those rare moments when I use C) or ICC (Intel C Compiler), though ICC is known for making code that runs slowly on AMD processors.

Peter C
  • 6,219
  • 1
  • 25
  • 37
2

Depends on the platform you are using and planning to learn on or will do future development.

On Windows you can use Visual Studio Express C++ which supports standard ANSI C usage. Option two is Cygwin which is a library and tool set that replicates much of what you would use on Linux or other Unix style OS's ( it uses GCC ).

On the Mac you would want XCode which is the standard development tools including C compiler ( based on GCC ).

On many Unix type systems it will be cc or gcc depending on the OS vendor.

If you have the money some of the paid compilers like the Intel one are exceptional but likely won't be much help in learning the programming craft at this point.

VHF
  • 174
  • 3
  • What about MinGW for Windows? – alternative Nov 09 '10 at 00:49
  • 3
    Visual Studio Express C++, according to Microsoft, does not support C99. And, I believe, there are no plans to make it do so either. – pmg Nov 09 '10 at 01:00
  • Visual Studio Express doesn't support x86-64 either. There used to be a work-around but MS changed the appearance of the registry so the work-around no longer applies. Besides Express installs a lot of junk so if you decide to back out you're looking at 25-30 uninstalls before you're done. – Olof Forshell Mar 05 '11 at 22:33
  • For enabling x86-64 in VSE 2010: http://msdn.microsoft.com/en-us/library/9yb4317s(v=vs.80).aspx – echristopherson May 19 '12 at 03:48
1

If you use LINUX operating system GCC is the best compiler. You can separate each compiler steps like preprocessing , assembler , linker separately in GCC compiler using some command line options. You can analyze step by step of compilation of your C source code easily. I suggest to go for "GNU C COMPILER(GCC)". You can use "CC" command, its nothing but a symbolic link to GCC.

Shashank
  • 34
  • 4
0

I can recommend OpenWatcom which was once used to develop Netware. Only supports IA-32 but does it well. Contains a basic IDE and a basic but competent profiler. Something for the real programmer :)

Then there is Pelles C which supports x86-64. It has a basic VC-like IDE but few support programs.

I like these two because the compilers are competent and you get going quickly without having to pore over manuals and wondering what the options mean.

Olof Forshell
  • 3,169
  • 22
  • 28
-3

gcc is best and free. GO FOR GNU!

prap19
  • 1,818
  • 3
  • 16
  • 26