[Coco] C compiler self-hosting on NitrOS9 again!

Jeff Teunissen deek at d2dc.net
Tue May 5 04:05:08 EDT 2020


On Tue, May 5, 2020 at 1:34 AM Bill Pierce via Coco
<coco at maltedmedia.com> wrote:

> All of the above will probably work fine for "most" people. I just can't use them to compile MShell or Ultimuse3. The reason being that in adding all the extra features (and fixing bugs), the line length and label count were reduced to make room. This is actually stated in the opening comments in one of the sources of the above files (I can't remember which, but I think it's c.prep18). Each one is just a tweeked version of the previous one.

The C preprocessor doesn't have (or need) a label count -- it doesn't
care about what kind of source you have. I think cpp's current maximum
_input_ line length is 255 characters, which should be enough, but I
could probably increase it without anything breaking too much. This is
important because the C preprocessor only works with exactly one line
at a time. When the C preprocessor is looking at a line of text, it
has already "forgotten" what was on the previous line, and all it's
doing is figuring out if it has to modify the line or if it can just
spit it back out.

It does not require a lot of working memory to be a C preprocessor.
All you need is an input buffer, a hash table to hold the patterns,
and an output buffer. If you're using static data areas to hold your
match and replacement patterns, you will run out of memory in a hurry,
so you don't do that...instead, you use malloc() or sbrk() to get
memory on the heap from the OS, and assign them in the order you
receive them.


More information about the Coco mailing list