Strange UNIX "icode" declaration in Lions' book

L

lovecreatesbeauty

I read the following code in `Lions' Commentary on UNIX 6th Edition
with Source Code'. The code in the book labeled from line 1516 to 1529
declaring "icode" is strange. Was one equal mark missed at line 1516
behind the right square brace?

1516 int icode[]
1517 {
1518 0104412, /*sys exec; init; initp*/
1519 0000014,
1520 0000010,
.... /*...*/
1529 };

lovecreatesbeauty
 
C

Chris Dollin

lovecreatesbeauty said:
I read the following code in `Lions' Commentary on UNIX 6th Edition
with Source Code'. The code in the book labeled from line 1516 to 1529
declaring "icode" is strange. Was one equal mark missed at line 1516
behind the right square brace?

1516 int icode[]
1517 {
1518 0104412, /*sys exec; init; initp*/
1519 0000014,
1520 0000010,
... /*...*/
1529 };

I seem to recall that once upon a time initialisers didn't need
an `=` sign. Sadly a quick google doesn't find supporting
evidence, apart from a very weak hint about a "change". Anyone
got a reference (for confimation or refutation)?
 
C

Chris Torek

lovecreatesbeauty said:
I read the following code in `Lions' Commentary on UNIX 6th Edition
with Source Code'. [missing "=" in initializer: "int i 3;" etc.]

I seem to recall that once upon a time initialisers didn't need
an `=` sign. Sadly a quick google doesn't find supporting
evidence, apart from a very weak hint about a "change". Anyone
got a reference (for confimation or refutation)?

In Version 6 C, initializers did not use "=":

int i 3;
int j[] { 0, 1, 2 };

In addition, if you started a file with any character other than "#",
the preprocessor did not run; so:

/* this is a V6 C program */

#define THIS 1

would not work as desired. (For this reason, a lot of V6 C programs
started with "#" on a line by itself.)

In similar oddness, one wrote, e.g.:

printf(2, "error message\n");

to send the printf() output to stderr. There was no fprintf() (not
until the "standard I/O library" was written, at least; and you
had to ask for that with "-lS" on the link line.)

Of course, none of this is even slightly odd compared to even-earlier
C:

struct (
int a; /* holds positive and negative values */
char *b; /* holds values from 0 to 65535 */
);

Yes, those are parentheses, not braces; and to hold unsigned integers,
one used pointers. (There was no "unsigned" keyword yet.)
 
L

lawrence.jones

Chris Dollin said:
I seem to recall that once upon a time initialisers didn't need
an `=` sign. Sadly a quick google doesn't find supporting
evidence, apart from a very weak hint about a "change". Anyone
got a reference (for confimation or refutation)?

K&R 1, A.17, Anachronisms:

The syntax of initializers has changed: previously, the equals
sign that introduces an initializer was not present...

-Larry Jones

I always send Grandma a thank-you note right away. ...Ever since she
sent me that empty box with the sarcastic note saying she was just
checking to see if the Postal Service was still working. -- Calvin
 
C

Chris Dollin

K&R 1, A.17, Anachronisms:

The syntax of initializers has changed: previously, the equals
sign that introduces an initializer was not present...

Thanks, Larry. I wish I'd thought to check the copy of K&R1 that I
happen to have on my shelf here ...

Obviously I should either migrate into virtual space, or devise a
googleike that works on physical books, scrappy notes, decaying
photocopies, and the remaining faint vibrations of long-passed
conversations.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,181
Messages
2,570,971
Members
47,537
Latest member
BellCorone

Latest Threads

Top