Subject: Re: option includes (was: Re: 19980623 build failure)
To: None <current-users@NetBSD.ORG, tech-kern@NetBSD.ORG>
From: Lucio de Re <lucio@proxima.alt.za>
List: tech-kern
Date: 06/25/1998 06:47:17
According to matthew green:
>
>    I committed a fix to ext2fs_extern.h yesterday which wraps the include
>    of opt_fifo.h under #if defined(_KERNEL)&&!defined(_LKM)
> 
> this has happened enough times now that i'm firmly of the opinion that all
> options header #includes should have above #ifdef construct around them to
> always avoid the lossage patrick had.
> 
This seems to need a rethink: the redundancy of wrapping the #include 
as well as its target in conditionals is just too prone to exactly the 
type of error we encounter here.

I presume from the above that there are situations where a header file 
is expected not to be _found_, otherwise internal conditionals would 
suffice.  There ought to be a less error-prone way: ideally, you'd want 
to include an empty file; alternatively, this may point to a flaw in 
the layout of the "include" tree.

I opt for the latter: I think it is reasonable to expect all header 
files mentioned in a source tree to be visible from any context in 
which that source tree is used.  This _before_ the preprocessor has 
had a chance to remove parts of the source protected by conditionals.

It is a philosophical point, but I believe it is a worthy objective.  
There may always be exceptions, but the intention is to keep these to a 
minimum.

And, while on the subject, in backporting some 1.3 sources to 1.1, the 
__COPYRIGHT macro gave me the biggest headache.  I eventually counted 
order of magnitude one thousand files (might have been more than two 
thousand, the way I recall) that would benefit from wrapping the 
__COPYRIGHT and __RCSID macros with an ifdef on __IDSTRING macro, 
rather than the "#if 0" or somesuch that was originally used (I was 
looking at the 1.3 source tree at the time).

In other words, this is my corrected version:

#if !defined(__IDSTRING)
static char sccsid[] = "@(#)xxxxxxx.c   8.4 (Berkeley) 5/30/95";
#else
__COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
    The Regents of the University of California.  All rights reserved.\n");
__RCSID("$NetBSD: xxxxxxx.c,v 1.5 1997/10/16 08:03:45 mikel Exp $");
#endif

which is backward compatible with the 1.1 environment.
Different original versions had, typically: 

#if 0
static char sccsid[] = "@(#)xxxxxxx.c   8.4 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: xxxxxxx.c,v 1.5 1997/10/16 08:03:45 mikel Exp $");
#endif

and then had __COPYRIGHT elsewhere in the text, unprotected.  I really 
think there are many, many such modules although if I used 
"grep COPYRIGHT" instead of "grep __RCSID" I may have counted way beyond 
reality :-(

I don't mind going through each source module in my own time and fixing 
this, but the problem is that making sure everything's complete before 
some change undoes all my work is no trivial endeavour.

++L