M
Malcolm McLean
I don't even use makefiles any more. Just gcc *.c -lm.cr88192 said:waiting for the preprocessor is not such a big problem anymore (nor are
build times that scarily long...).
I don't even use makefiles any more. Just gcc *.c -lm.cr88192 said:waiting for the preprocessor is not such a big problem anymore (nor are
build times that scarily long...).
I'm well aware of who Rob Pike is The notes you reference were]> The given extract does not recommend against using header guards,
nordoes it actually recommend not including headers within headers. It
does give one example of not doing so, but no rationale. Perhaps there
are reasons not to change an existing libc.h.
IAC, this is sure to *add* to maintenance headaches, not reduce them,
and the only flexibility it adds is the opportunity to scratch your
head about which headers are missing. Sorry, I don't see the benefit.
That's the opinion of Al Balmer.
Let's see what Rob Pike's opinion is, shall we?
Who is Rob Pike? http://herpolhode.com/rob/
Al Balmer said:While I respect Mr. Pike and the contributions he's made, IMO he's all
wet on this issue. He apparently expects that the programmer read
every header before using it, or at least inspects it for comments
specifying its prerequisites.
On Mon, 28 Jan 2008 12:59:17 -0800 (PST), fnegroni
The notes you reference were
written in disagreement of practices espoused by Brian Kernighan and
P. J. Plauger. (I suppose you know who they are?)
Why should mylib.h, a third party file which I should not have to
modify, include <stdio.h> just because it uses FILE ?
Surely I can supply my own header which defines a compatible but
otherwise different implementation of FILE * that satisfies the
requirements of mylib (and mylib.h).
Version one of mylib.h does no IO. Someone decides to provide load / savesfnegroni said:So why is it that a standard header never includes another standard
header?
Why should mylib.h, a third party file which I should not have to
modify, include <stdio.h> just because it uses FILE ?
Surely I can supply my own header which defines a compatible but
otherwise different implementation of FILE * that satisfies the
requirements of mylib (and mylib.h). Why should mylib.h override my
definition of FILE ?
usually, this is a minor problem (rarely has this been a problem in
practice).
whatever dude...
it is not like we are a bunch of monkeys bashing on a keyboard.
theoretically we have enough brains to know just what the hell we wrote...
it introduces increased cost in terms of dependency management, which IS
a problem in practice.
of course, a matter of scale is also involved (I am thinking more in the
hundreds of kloc range).
not often the case as I have seen with 3rd party libraries.
also, note that, when codebases get large, it is a major hassle to drag
around much more than pieces of previous projects.
grab pieces, tack them together, make something that works.
we don't want to drag in 500kloc or 1Mloc of code just to get some
simple app working, it is better just to grab what is needed. this
means, keeping some level of control over dependency issues.
it is also much worse, for example, when a bug or change in one part of
the codebase, due to uncontrolled dependencies, manages to disrupt the
operation of many of the other subsystems (or leaves the pain of having
to rewrite a part of the codebase to break up these dependencies).
of course, this only assumes the people have read the documentation.
this is especially a problem with building cross-platform apps and libs
(or trying to get most linux apps to build on windows).
it is best to avoid using anything that may not exist on the other arch.
fnegroni said:Surely I can supply my own header which defines a compatible but
otherwise different implementation of FILE * that satisfies the
requirements of mylib (and mylib.h).
Why should mylib.h override my definition of FILE ?
If you worked here, I would give you a very practical reason. Your
code would be rejected at review, and you would be told to fix it and
not do something like that again.
Malcolm said:Version one of mylib.h does no IO. Someone decides to provide load /
saves for version 2, and the functions take FILE * parameters. So your
code could easily break.
Sure.
Next?
There's a little dance involving #ifdef's that can prevent a
file being read twice, but it's usually done wrong in practice - the
#ifdef's are in the file itself, not the file that includes it. The
result is often thousands of needless lines of code passing through
the lexical analyzer, which is (in good compilers) the most expensive
phase.
fnegroni said:The
result is often thousands of needless lines of code passing through
the lexical analyzer, which is (in good compilers) the most expensive
phase.
hundreds of files, all of which have to be updated...
I won't deny this was issue in 1989 (I worked on one Encore mini where
it took on the order of 6 hours to rebuild the world, although that
was Ada, not C), but I like to think we've made *some* progress over
the last couple of decades.
Building our product on a mere quad core xeon with 4GB ram only takes
a mere 2 hours.
But then we compile our code on 26 platforms, some are even slower...
And you would do that manually? Ever heard of sed?
I am just saying there are people who beg to differ in their opinion,
and those opinions have their merits.
You disagree with me, fine. Just don't tell me to shut up or get a job
somewhere else, because that just sounds to me like you just need a
fix.
So why is it that a standard header never includes another
standard header?
fnegroni said:Building our product on a mere quad core xeon with 4GB ram only takes
a mere 2 hours.
I don't agree with the no-including-headers-in-headers view, but
this is a good question which I don't see has been answered. It has
always seemed odd to me that, for instance, NULL is defined in more
than one standard header file. Why wasn't it put in, say, stddef.h
with stddef.h then #included in stdio.h, stdlib.h, etc.? (It seems
to violate the DRY principle, which is something *I* never do ;-)
I'll bet this is covered in P.J. Plauger's Standard C Library, but
my copy is at home. Is it just a historical artifact? Anyone care
to explain?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.