Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

My box is configured:

Ubuntu, Code::Blocks IDE, GNU gcc compiler.

I'm not very experienced in C. I am having some difficulty seperating what functions are available to me. Evidently there's a few different compiler versions and they have different libraries available.

Is there an official GNU gcc compiler reference for C? I've considered buying K&R, but I think that is too much for someone at my skill level. Do you have any other tips for free C references considering my setup?

share|improve this question
    
K&R is a great book (even if you're a beginner - hmm maybe especially if you're a beginner!) but it is not a gcc compiler reference guide. It is about the language, not a specific compiler. –  FrustratedWithFormsDesigner Apr 27 '11 at 13:47
    
The answer partly depends on whether you're unfamiliar with the C language or implementation extensions to C, but you likely don't know which is which. Get K&R so you know what real C90 is. –  David Thornley Apr 27 '11 at 20:12
add comment

2 Answers

up vote 1 down vote accepted

K&R is exactly what you need for your skill level, although it's a little out-of-date (it doesn't cover the additions from the 1999 standard).

Neither does it cover gcc-specific extensions, but frankly it's better to learn the basic language before learning a specific implementation of it1. Use the -ansi or -std=c89 or -std=c90 command-line options to compile code from K&R. These will disable any gcc-specific extensions that conflict with the 1989/1990 standard.

As for gcc itself, you can find the online manuals here.


1. Way too many people who should know better confuse a specific implementation of C with the language itself. The first edition of Schildt's "C: The Complete Reference" assumed you were working in Microsoft Visual C and all of the examples relied on MS-specific extensions, but he never told you what was basic to C and what was specific to MSVC. Since I was working on VAX/VMS, none of the examples would compile for me because VAX C didn't define conio.

share|improve this answer
add comment

Another (gcc-specific, but there are equivalents for other compilers) word of advice: get in the habit, now, of always invoking gcc with the flags

-Wall -Werror

these flags will instruct gcc to a.) warn about any likely problems it sees in your code, and b.) refuse to continue compilation if any such likely problems are encountered.

Later, when you have more experience, you will find cases where you need to silence one or more specific warnings (and you'll know how by then). For now, you should be assuming that if the compiler sees a problem, it's right.

Working this way will help build sound coding habits, and help dodge one of the main pitfalls of C programming for beginner and expert alike: the fact that most wrong (even dangerously wrong) programs will compile and (try to) run, mostly due to C's rather fast-and-loose type checking.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.