builtins and automatic defines

KW Heuer kwh at bentley.UUCP
Fri May 23 08:31:13 AEST 1986


In article <1243 at utcs.uucp> utcs!flaps (Alan J Rosenthal) writes:
>In article <816 at bentley.UUCP> kwh at bentley.UUCP (KW Heuer) writes:
>>I wonder if perhaps <stdio.h> (and <builtins.h>) should be included by
>>default, with an explicit "#exclude" to disable.  (Cf. "#undef".)  Probably
>>tricky to implement -- don't do the automatic "#include" until checking for
>>"#exclude", which must be at the top of the file (after whitespace)?
>
>Why bother?  This would be very complicated and lead to many mistakes due
>to an unclear definition of whitespace or whatever.

It doesn't seem all that complicated to me, and probably seems simpler to
the neophyte who doesn't understand why he gets "stderr undefined" when his
program was working fine earlier.  The mistakes could be easily caught by
cpp: "#exclude must be at top of file".  I meant for "whitespace" to include
comments, otherwise I think it's quite clear (when restricted to the set of
characters that can legally appear in a C program).

>I have a file called "beginc", it's a shellscript, and it creates a file
[which contains several #include's and #define's and the start of main()]
>and then puts you in $EDITOR on the file.  This approach is much better
>than any #exclude op.  It's more easily disabled or modified because you
>don't have the reverse situation of deleting things by adding in lines.

Perhaps.  We already have the "delete by adding" situation with #undef,
though the analogy isn't perfect (you can't completely cancel an #include,
which is why #exclude would have to be first).

On a related note, I've always despised the automatic cpp builtins (such as
"#define unix 1" on UNIX(R) systems), because it effectively creates a new
reserved word for each possible operating system, machine, etc. that your
program might be compiled on.  Older versions got around this by making the
builtin definition be "#define unix unix", with a special kludge to prevent
infinite recursion.  I think the "who am i" testing should not use the same
namespace as the macros.

Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint



More information about the Comp.lang.c mailing list