This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Projects for beginners


Richard Kenner wrote:

>     It also effectively sets those dependencies in concrete. If, for any
>     reason, the dependencies change for a particular header, you have to
>     change all sources that include it.
> 
> From a conceptual point of view, you do anyway.  A header is a specification
> of something which is implemented in a .c file.  If the specification
> of something changes, you have to look at all callers to make sure they
> reflect the change of specification.

 From a conceptual point of view there's no difference between coding in 
assembly and coding in C, either. Both are a specification for a set of 
machine-code instructions. ...

First of all, a C header is /not/ an interface specification. It can 
contain anything you like. That headers most often happen to be used for 
interface definitions only means that people find that the most useful 
use for headers. That's easiest to do if all you have to know is which 
interfaces a header provides, without worrying about its dependencies on 
other interfaces (that may be in other headers). Imagine the chaos if 
ISO C didn't require standard headers to be idempotent!

More important IMHO is that changing a header does not necessarily 
always imply a change to the interface. Refactoring for better code 
sharing or perhaps faster compilation is fairly common; having to know 
to the tiniest detail which header is included in which file makes it 
practically impossible. You end up merging code instead into many-100K 
source files instead of breaking them up in manageable pieces, simply 
because it's too much of a pain to figure out what exactly you should 
include where.


O.K., that was considerably more than my $0.02, and since I'm not 
volunteering for any include-guard drudgery, I'll just leave the arguing 
to those that are.

-- 
Brane Čibej
    home:   <brane@xbc.nu>             http://www.xbc.nu/brane/
    work:   <branko.cibej@hermes.si>   http://www.hermes-softlab.com/
     ACM:   <brane@acm.org>            http://www.acm.org/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]