Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Best book on C gotchas and best practices?

255 views
Skip to first unread message

Chicken McNuggets

unread,
Jul 30, 2013, 10:57:04 PM7/30/13
to
I'm pretty up to speed with C but I still feel there are areas that I
make mistakes in my design and implementation. Would anyone recommend
the best book that deals with these kinds of issues? Obviously I already
have K&R, and the C11 standard document for reference but I was looking
for something a bit more focused on how to avoid common mistakes or
anti-patterns.

Any help is appreciated.
--
comp.lang.c.moderated - moderation address: cl...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.

Eric Sosman

unread,
Jul 31, 2013, 10:21:28 PM7/31/13
to
On 7/30/2013 10:57 PM, Chicken McNuggets wrote:
> I'm pretty up to speed with C but I still feel there are areas that I
> make mistakes in my design and implementation. Would anyone recommend
> the best book that deals with these kinds of issues? Obviously I already
> have K&R, and the C11 standard document for reference but I was looking
> for something a bit more focused on how to avoid common mistakes or
> anti-patterns.

Andrew Koenig's "C Traps and Pitfalls" is worth a lukewarm
recommendation. "Lukewarm" for two reasons:

- First and more important, it's aimed at people making the
transition from pre-Standard to ANSI C, and is nowadays
rather dated.

- Second and less important, it goes out of its way to say
that the printf() specifier "%8%" is well-defined (even in
the original ANSI Standard it was a constraint violation).

--
Eric Sosman
eso...@comcast-dot-net.invalid

ralph

unread,
Jul 31, 2013, 10:22:06 PM7/31/13
to
On Tue, 30 Jul 2013 21:57:04 -0500 (CDT), Chicken McNuggets
<chi...@mcnuggets.com> wrote:

>I'm pretty up to speed with C but I still feel there are areas that I
>make mistakes in my design and implementation. Would anyone recommend
>the best book that deals with these kinds of issues? Obviously I already
>have K&R, and the C11 standard document for reference but I was looking
>for something a bit more focused on how to avoid common mistakes or
>anti-patterns.
>

While not C specific, every begining programmer should add Steve
McConnell's "Code Complete" 2nd edition to their library.

http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670

-ralph

Chris Riesbeck

unread,
Jul 31, 2013, 10:23:20 PM7/31/13
to
On 7/30/2013 9:57 PM, Chicken McNuggets wrote:
> I'm pretty up to speed with C but I still feel there are areas that I
> make mistakes in my design and implementation. Would anyone recommend
> the best book that deals with these kinds of issues? Obviously I already
> have K&R, and the C11 standard document for reference but I was looking
> for something a bit more focused on how to avoid common mistakes or
> anti-patterns.
>
> Any help is appreciated.

Koenig C Traps and Pitfalls
van der Linden Expert C Programming: Deep C Secrets

Keith Thompson

unread,
Aug 1, 2013, 1:57:46 PM8/1/13
to
Eric Sosman <eso...@comcast-dot-net.invalid> writes:
> On 7/30/2013 10:57 PM, Chicken McNuggets wrote:
>> I'm pretty up to speed with C but I still feel there are areas that I
>> make mistakes in my design and implementation. Would anyone recommend
>> the best book that deals with these kinds of issues? Obviously I already
>> have K&R, and the C11 standard document for reference but I was looking
>> for something a bit more focused on how to avoid common mistakes or
>> anti-patterns.
>
> Andrew Koenig's "C Traps and Pitfalls" is worth a lukewarm
> recommendation. "Lukewarm" for two reasons:
>
> - First and more important, it's aimed at people making the
> transition from pre-Standard to ANSI C, and is nowadays
> rather dated.
>
> - Second and less important, it goes out of its way to say
> that the printf() specifier "%8%" is well-defined (even in
> the original ANSI Standard it was a constraint violation).

It's not a constraint violation. It's probably undefined behavior.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Eric Sosman

unread,
Aug 1, 2013, 10:06:05 PM8/1/13
to
On 8/1/2013 1:57 PM, Keith Thompson wrote:
> Eric Sosman <eso...@comcast-dot-net.invalid> writes:
>> On 7/30/2013 10:57 PM, Chicken McNuggets wrote:
>>> I'm pretty up to speed with C but I still feel there are areas that I
>>> make mistakes in my design and implementation. Would anyone recommend
>>> the best book that deals with these kinds of issues? Obviously I already
>>> have K&R, and the C11 standard document for reference but I was looking
>>> for something a bit more focused on how to avoid common mistakes or
>>> anti-patterns.
>>
>> Andrew Koenig's "C Traps and Pitfalls" is worth a lukewarm
>> recommendation. "Lukewarm" for two reasons:
>>
>> - First and more important, it's aimed at people making the
>> transition from pre-Standard to ANSI C, and is nowadays
>> rather dated.
>>
>> - Second and less important, it goes out of its way to say
>> that the printf() specifier "%8%" is well-defined (even in
>> the original ANSI Standard it was a constraint violation).
>
> It's not a constraint violation. It's probably undefined behavior.

You're right: The "shall" is not in a constraints section,
so violating it yields undefined behavior. Sorry for the
misstatement, and thanks for the correction!

--
Eric Sosman
eso...@comcast-dot-net.invalid

Fred J. Tydeman

unread,
Aug 5, 2013, 12:24:10 PM8/5/13
to
On Wed, 31 Jul 2013 02:57:04 UTC, Chicken McNuggets <chi...@mcnuggets.com> wrote:

> I'm pretty up to speed with C but I still feel there are areas that I
> make mistakes in my design and implementation. Would anyone recommend
> the best book that deals with these kinds of issues?

Perhaps:
Portability and the C Language by Rex Jaeschke
---
Fred J. Tydeman Tydeman Consulting
tyd...@tybor.com Testing, numerics, programming
+1 (775) 287-5904 Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.
0 new messages