Home > Software design >  Is there any documentation for pre-K&R c?
Is there any documentation for pre-K&R c?

Time:12-19

I was playing around with an online PDP11 emulator (link) and was looking at the programming section of its FAQ.

It says this about programming in C on the emulator:

You need to write pre-K&R C which is quite a bit different from modern C

I believe this is referring to the version of C in use before the publication of The C Programming Language. I have tried to understand this version by reading the sparse C files I can find in the emulator's filesystem, but even simple things like declaring argc and argv have eluded me. I also can't find anything about it online.

Is there any documentation, written at the time or after the fact, on "pre-K&R" C?

CodePudding user response:

For this sort of question, my go-to source is the archived web page of the late Dennis Ritchie:

https://www.bell-labs.com/usr/dmr/www/

From there it's one click to this early reference manual for C, written by Ritchie himself:

https://www.bell-labs.com/usr/dmr/www/cman.pdf

This is indeed "pre-K&R C", featuring anachronisms such as = instead of =.

This is the same reference manual that appeared, in updated form, as Appendix A in the K&R book.

On the same page are links to several other versions of that reference manual, as well as notes about and even the source code of two early versions of Ritchie's compiler. These are pretty fun to look at, although as the page notes, "You won't be able to compile them with today's compilers".

There's a whole Stack Exchange site dedicated to questions like these: https://retrocomputing.stackexchange.com/.

CodePudding user response:

Steve Summit answered about where to get the documentation. So this post is intended to summarize noticeable differences from modern C

Types for function arguments were quite different. They were not specified within the parenthesis

void foo(a, b)
    int a; 
    float b;
{
    // Function body
}

No row comments, like //. Only /* */

No logical or and and. The operators && and || did not exist. The bitwise operators & and | were used instead.

=- meant the same as -=, which lead to ambiguity with for instance x=-1.

There was no void pointers. char pointers were used instead.

One could not declare variables in the for header, so one had to write:

int i=0; 
for(i=0; i<N;   i)
  • Related