I
Ioannis Vranos
C90:
From the K&R2 errata site: http://tinyurl.com/3nbvbh
1.
"...
Also, the comparison-routine argument is not treated well. The call
shown on p 119, with an argument
(int (*)(void*,void*))(numeric? numcmp : strcmp)
is not only complicated, but only barely passes muster. Both numcmp and
strcmp take char * arguments, but this expression casts pointers to
these functions to a function pointer that takes void * arguments.
==> The standard does say that void * and char * have the same
representation, so the example will almost certainly work in practice,
and is at least defensible under the standard. There are too many
lessons in these pages".
Does the C90 standard guarantee that "void * and char * have the same
representation"?
2.
"143(§6.5): strdup is not indexed".
What does that mean?
3.
"195(§A4.1) The first few sentences might be reworded a bit to emphasize
that there is a distinction between storage duration and scope, though
both are influenced by explicit and implicit storage-class specifiers".
Can anyone provide a solution for this?
4.
"245(§B1.3, and also at p. 157 §7.4): The scanf functions do not ignore
white space in formats; if white space occurs at a place in the format,
any white space in the corresponding input is skipped".
I am confused on this. When we do scanf("%d%d", &x, &y); when we enter
whitespaces they don't get ignored?
5.
"246(§B1.3): In table B-2, arguments corresponding to o, x, X, u are
unsigned int *".
The table B-2 doesn't mention 'X'. Any ideas?
6. "There is no mention of the offsetof macro in §B".
Can anyone provide a solution for this?
From the K&R2 errata site: http://tinyurl.com/3nbvbh
1.
"...
Also, the comparison-routine argument is not treated well. The call
shown on p 119, with an argument
(int (*)(void*,void*))(numeric? numcmp : strcmp)
is not only complicated, but only barely passes muster. Both numcmp and
strcmp take char * arguments, but this expression casts pointers to
these functions to a function pointer that takes void * arguments.
==> The standard does say that void * and char * have the same
representation, so the example will almost certainly work in practice,
and is at least defensible under the standard. There are too many
lessons in these pages".
Does the C90 standard guarantee that "void * and char * have the same
representation"?
2.
"143(§6.5): strdup is not indexed".
What does that mean?
3.
"195(§A4.1) The first few sentences might be reworded a bit to emphasize
that there is a distinction between storage duration and scope, though
both are influenced by explicit and implicit storage-class specifiers".
Can anyone provide a solution for this?
4.
"245(§B1.3, and also at p. 157 §7.4): The scanf functions do not ignore
white space in formats; if white space occurs at a place in the format,
any white space in the corresponding input is skipped".
I am confused on this. When we do scanf("%d%d", &x, &y); when we enter
whitespaces they don't get ignored?
5.
"246(§B1.3): In table B-2, arguments corresponding to o, x, X, u are
unsigned int *".
The table B-2 doesn't mention 'X'. Any ideas?
6. "There is no mention of the offsetof macro in §B".
Can anyone provide a solution for this?