Errata

21st Century C

Errata for 21st Century C

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Ch13
Section: "The GNU Scientific Library" Code listing: "Example 13-4"

The notes underneath the code listing for "Example 13-4" don't link back to the specific line of code that the note is talking about.

Note from the Author or Editor:
I'm unable to replicate, in that it seems that 13-4 has identical treatment to all the other callouts throughout (in the source for the book and the safari version). Is this something about the processing from source -> safari?

Yung-Jin (Joey) Hu  Apr 16, 2017 
?
Example 1.1

You write "(for me, at least; if the statistical jargon is Greek to you, that’s OK)"

Can you point to learning resources if that's indeed Greek to me, and I'm not OK with not understanding. The problem comes up again later in Example 1.3.

Thanks for considering people with a lesser grasp of statistics.

Anonymous  Jul 05, 2019 
Printed Page 47
4th paragraph

p xmlElemDump(stdout, $arg0, xmlDocGetRootElement($arg0))

should read

p (void) xmlElemDump(stdout, $arg0, (xmlNodePtr) xmlDocGetRootElement($arg0))

gdb 9.1 under Ubuntu (at least) complains about unknown return types unless both xmlElemDump and xmlDocGetRootElement are cast.

bl4krat  Sep 04, 2020 
Other Digital Version 52
1402 of 10985 of the Kindle Edition

The book states to use "valgrind --db-attach=yes your_program"; however, that option appears to be deprecated. I'm on Debian 9 using valgrind-3.12.0.SVN. I believe the modern-equivalent is "--vgdb=no|yes|full --vgdb-error=0"

Andy Alt  Dec 14, 2018 
Other Digital Version 56
Location 1494 in the Kindle Edtion

I'm reading from the Kindle Edition, and using Debian 9, automake v1.15.

"check_CFLAGS += -DTest_operations" had no effect when I tried it ("Test_operations" didn't get derfined). I needed to precede _CFLAGS with the name of the source library:

check_LIBRARIES = librmw.a
librmw_a_SOURCES = $(rmw_SOURCES)
librmw_a_CFLAGS = $(AM_CFLAGS) -DTEST_LIB

Andy Alt  Dec 10, 2018 
Printed Page 153
Example 7-2 in main() at call to at_quick_exit

On OS X Mojave, the compiler gives a warning when compiling noreturn.c with CFLAGS="-Wall -g -std=gnu11 -O3":

noreturn.c:27:5: warning: implicit declaration of function 'at_quick_exit' is invalid in C99

Checking stdlib.h on my Mac, 'quick_exit()' and 'at_quick_exit()' are indeed not defined. I did some research online and it seems to be a known issue for OS X, but couldn't find a solution. (It works perfectly fine though on Ubuntu, but I thought it would be good to mention)

Artagan Malsagov  Nov 28, 2020 
Printed Page 155
Third to last paragraph

The sentence "That's for a 32-bit float, which is the minimum standard anymore." I think the second part should be "...,which isn't the standard anymore."?

Artagan Malsagov  Nov 28, 2020 
Printed Page 174
First and second paragraph

1) First sentence of first paragraph: "...and some of the year-month values above...", I don't think there where any year-month values used in Ch.8

2) First sentence of second paragraph: "...than the #if /#error/ #endif form...". I think this should be #ifndef /#error /#endif form? Similarly for the first sentence of the third paragraph?

Artagan Malsagov  Dec 06, 2020 
Printed Page 177
Example before last paragraph of "Linkage with static and extern"

In the example for header file "common_fns.h" the function:

static long double max(long double a. long double b){
( a > b) ? a : b;
}

does not have a return statement. I think it should be:

return (a > b) ? a : b;



Artagan Malsagov  Jan 02, 2021 
Printed Page 183
1st paragraph

The second sentence of the first paragraph (after example 8-6): "But when you compile it, you'll find that you get a warningclang says:...". I think "warning" and "clang" should be separated.

Artagan Malsagov  Jan 03, 2021 
Printed Page 183-184
Example 8-7

When I compile constfusion.c on Mac OS X, I get the clang warning about discarding qualifiers in nested pointer types, but the output is:

x=20 y=30

So the assignment of *var=30 did not lead to fixed=30 when compiling with clang, is this normal?

Artagan Malsagov  Jan 03, 2021 
Printed Page 183-184
Example 8-7

PS: result from question above (submitted Jan 03, 2021) resulted from compiling constfusion.c with:

export CFLAGS="-g -std=gnu11 -O3"
make constfusion

Artagan Malsagov  Jul 15, 2021 
Printed Page 188
Example 9-2

When compiling getstrings.c on Linux Ubuntu (and also when compiling sasprintf.c) I get a warning about ignoring the return value of asprintf:

getstrings.c:11:5: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
asprintf(&cmd, "strings %s", in);

In the spirit of treating warnings as seriously as possible, is there a way of telling the compiler that this is oke? Or should one always assign the return value of asprintf and do something with it?

Artagan Malsagov  Feb 14, 2021 
Printed Page 188
Example 9-2

PS: warning above resulted from compiling getstrings.c with

export CFLAGS="-g -Wall -std=gnu11 -O3" #the usual.
make getstrings


Artagan Malsagov  Jul 15, 2021 
Printed Page 189
Example 9-3

When compiling asprintf.c on MacOS the following error is generated:

*********************************************************************************************
asprintf.c:15:5: error: conflicting types for 'asprintf'
int asprintf(char **str, char* fmt, ...){
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:374:6: note: previous declaration is here
int asprintf(char ** __restrict, const char * __restrict, ...) __printflike(2, 3);
*********************************************************************************************

When I rename the function to asprintf1 it works perfectly fine; is this a quirk of clang perhaps?

Artagan Malsagov  Mar 02, 2021 
Printed Page 189
Example 9-3


PS: result from question above (submitted Mar 02, 2021) resulted from compiling asprintf.c with:

CFLAGS="-g -Wall -std=gnu11 -O3 -DTest_asprintf" make asprintf

Artagan Malsagov  Jul 15, 2021 
Printed Page 193
Example 9-4

In example 9-4, sasprintf.c is missing preprocessor directive for asprintf:

#define _GNU_SOURCE

Example code in github repo does have it though.



Artagan Malsagov  Jan 28, 2021 
Printed Page 240
Example 10-19

In the book, Example 10-19 misses the preprocessor directives to include asprintf. In the code on github these are included, but in the book example not.

#define _GNU_SOURCE //cause stdio.h to include asprintf
#include <stdio.h> //asprintf

Artagan Malsagov  Mar 03, 2021