It's a nightmare for both the implementor and the user. Consider
things like size_t and NULL, that are supposed to be available in
several headers: if the implementor wants to change one of them, he
must take care to change *all* the headers defining/declaring the
identifier in question.
If you see the following in a header:
void foo(FILE *);
then this header implicitly states that <stdio.h> must be included first.
I guess Pike was either drunken or stoned when he suggested that the
users of a header actually read the header in order to figure out its
dependencies.
Dan
I didn't read Pike's original statements but I guess I am exposed to
an even stricter style guide: within a client company of mine there is
the rule that every header file has to have an "PRIVATE" section which
defines (not declares!) all file-global objects. Below there needs to
be a "PUBLIC" (or EXTERN, I don't remember) and a "COMMON" section
which declare the respective "purely extern" objects which are
exported by this module (whatever that means) and the shared objects.
Yes, I am still talking C, though the creator admits that his
construct is influenced by a C++ class definition. For a clearer idea
let me picture a typical header file as it is required to be:
foo.h (accompanying header file to foo.c)
typedef int bar; // common section for all
#ifdef _PRIVATE
#undef _PRIVATE
// used inside foo.c
bar Global;
bar foo(void);
#else
// used outside of foo.c
extern bar Global;
extern bar foo(void);
#endif
foo.c has to include foo.h as the last header file, with a preceding
#define _PRIVATE
And yes, the "no include includes others"-rule is in effect too.
Aside from the bad but sometimes inevitable global variables, I
consider this style ultimately evil, but I lack the proper verbal
ammunition to sink it. Anyone who can help with a list of unbeatable
arguments against it?
Mark