|
|
|
|
|
by geokon
3072 days ago
|
|
What I liked about this book is that it's very upfront about how messed up C is. I read about half of it and it made me never want to write any C ever again. An especially memorable part for me was how it took 3 pages of language lawyering to explain why this doesn't compile: foo(const char **p) { }
main(int argc, char **argv)
{
foo(argv);
}
|
|
It takes quite a bit to explain because the "common sense" is that if one level of pointer indirection allows you to pass non-const where const is expected, then two levels shouldn't be any different. But common sense is wrong, and the compiler is right. And it doesn't require any language lawyering, either - all you need to do is slightly tweak the example to show why exactly it is unsafe.