The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: paul.winalski@gmail.com (Paul Winalski)
Subject: [TUHS] origin of C header files
Date: Fri, 29 Dec 2017 20:52:00 -0500	[thread overview]
Message-ID: <CABH=_VTdaxXqsoi=YUAwChtY3=5HvPeoX4vxmpOmiTjkiYW0TQ@mail.gmail.com> (raw)
In-Reply-To: <fd3b30a3c9531404ba67c9abcfcd2581ddc9aa2c@webmail.yaccman.com>

On 12/29/17, Steve Johnson <scj at yaccman.com> wrote:
> I begged Dennis for a solution, and he came up with #line,
> which allowed you to say to the C compiler "treat the next line as if
> it were line nnn in file fff, and following lines as successor lines
> in file fff.  It instantly solved the problem, and was used multiple
> times for various applications (probably most notably cfront).  So
> far as I know, many languages including FORTRAN, Pascal and Python do
> not have such a mechanism, making it awkward to use them as
> preprocessor targets.

Language processing systems where the preprocessor functionality is
implemented as a part of the compiler itself never had the "associate
the error message with the line in the original source" problem that
you described.  The compiler could keep an internal table mapping the
lexical output of the preprocessor to the source lines/files that went
into the preprocessor phase.  Most (all?) of DEC's and IBM's compilers
operate this way.

In keeping with UNIX's philosophy of "one image/one purpose", C's
preprocessor functionality was in a separate image from the compiler
itself.  There are many advantages to this design, including that cpp
can then be used for other languages than C.  But is has the
disadvantage of introducing the source correlation problem that
required the introduction of #line.

-Paul W.


  reply	other threads:[~2017-12-30  1:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-29  8:26 Wesley Parish
2017-12-29 10:58 ` Nigel Williams
2017-12-29 19:28 ` Paul Winalski
2017-12-29 20:31   ` Clem Cole
2017-12-30  1:06     ` Steve Johnson
2017-12-30  1:52       ` Paul Winalski [this message]
2018-01-23  4:27         ` Steve Johnson
2017-12-31  2:32 Doug McIlroy
2018-01-12  8:44 Lars Brinkhoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABH=_VTdaxXqsoi=YUAwChtY3=5HvPeoX4vxmpOmiTjkiYW0TQ@mail.gmail.com' \
    --to=paul.winalski@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).