I found the old C compiler from V6, and, though it seems to the modern eye a little different from good, idiomatic C, evidently it uses things like #include and #define, but I do not see how it implements these.

Was this an external program at that time? In that case, is it lost to obscurity or am I missing something in this codebase?

  • 9
    Not sure, but wasn't cpp, the preprocessor an external tool anyway?
    – Raffzahn
    Commented Mar 9, 2021 at 10:49
  • @Raffzahn Yes, but nowadays (clang/gcc) the external cpp tool is only provided for compatibility and you should invoke cc -E on those compilers instead, otherwise some expansions might not succeed properly.
    – ljrk
    Commented Mar 9, 2021 at 18:40
  • 2
    my eyes! it seems to perform complete manual parsing. Must have been horrible to write. BTW which compiler was used to compile this C compiler for first pass??? Commented Mar 9, 2021 at 20:36
  • 4
    @Jean-FrançoisFabre It was made in incremental steps from a B compiler actually. I'm pretty sure there's a question on this site about that Commented Mar 10, 2021 at 6:50

1 Answer 1


In V6, the C preprocessor is part of cc, the compiler driver; see the expand() function in cc.c. The directory you linked to contains the source code to the two passes of the C compiler, c0 and c1 (and their floating-point variants, fc0 and fc1), and the optional optimiser, c2. The passes are driven by cc, whose source code is available in the s1 directory.

As far as I can tell, the external preprocessor was introduced in V7.

In both cases, the preprocessor can be invoked using cc -P. The V6 and V7 cc(1) manpages provide more detail. Dennis M. Ritchie’s The Development of the C Language paper gives this context:

Many other changes occurred around 1972-3, but the most important was the introduction of the preprocessor, partly at the urging of Alan Snyder, but also in recognition of the utility of the the file-inclusion mechanisms available in BCPL and PL/I. Its original version was exceedingly simple, and provided only included files and simple string replacements: #include and #define of parameterless macros. Soon thereafter, it was extended, mostly by Mike Lesk and then by John Reiser, to incorporate macros with arguments and conditional compilation. The preprocessor was originally considered an optional adjunct to the language itself. Indeed, for some years, it was not even invoked unless the source program contained a special signal at its beginning. This attitude persisted, and explains both the incomplete integration of the syntax of the preprocessor with the rest of the language and the imprecision of its description in early reference manuals.

The “special signal at its beginning” is # as the very first character; this test can be seen in V5’s cc.c (and in V6’s).

(I’m linking to Diomidis Spinellis’ Unix history repo because I’m familiar with it, but the repo you’ve found also has cc in s1.)

  • 7
    It was internal, then external, and nowadays internal again?
    – dave
    Commented Mar 9, 2021 at 13:01
  • 4
    Given that C evolved at around the same time as the invention of pipes, I am not surprised that an early version of C would have an internal preprocessor.
    – DrSheldon
    Commented Mar 9, 2021 at 15:54
  • 3
    The history I always learned was that, early on, the preprocessor was a separate program, and was only executed if the driver script saw a '#' as the very first byte of the source file. But what version that applied to, I can no longer say. By the time I wrote C, the preprocessor always ran (though it might still have been separate).
    – dave
    Commented Mar 9, 2021 at 17:02
  • 3
    @texdr.aft from the user’s perspective though the C compiler was cc; I don’t think the separate passes were run directly by users (or at least, by most users). Commented Mar 9, 2021 at 17:18
  • 3
    @StephenKitt Right. I suppose my point was that cc and the compiler proper were not the same executable.
    – texdr.aft
    Commented Mar 9, 2021 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .