CompuServe Messages

Small code

    12-Dec-87 16:53:53
Sb: #97860-Small code
Fm: Glenn Nielsen 75115,444
To: Paul Montgomery 71500,3525
Paul, I couldn't find small.arc in the DL's. I looked at avail.c on Disk 4 of Lattice 4.0. Seems that there are some interesting, undocumented tricks going on in the first 5 lines of avail.c. Did you read the Read.Me file in the same directory? Some interesting stuff! After looking it over, 'echo' on the first line of avail.c seems to do two things. When you execute avail.c, it prints a blank line. When avail.c is compiled it declares 'echo' to be an int. Since LC seems to do this automagically, they use the int 'echo' for holding the value of stdout required for the printf statements in avail.c. Notice the line echo = int(Output()); in avail.c. printf wouldn't know where to send it's output if stdout wasn't defined, hence the 'DEFINE _stdout=_echo' argument for blink. The only reason I can see for doing this is to save 4 bytes in the final program. <Glenn P.S. I'm picking up a few things from this thread myself!