Cake (was Recursive #includes)

Dave Jones djones at megatest.UUCP
Sat Mar 4 07:30:52 AEST 1989


>From article <20078 at santra.UUCP>, by alo at kampi.hut.fi (Antti Louko):
> 
> When I saw cake first time, it seemed just fine. But after a while I
> realized one thing. After that I haven't used cake anymore.
> 
> Lets have an Cakefile:
> 
> $ cat Cakefile
> vax:	/dev/null
> 	cp /dev/null vax
> 
> $ cake
> cp /dev/null 1
> $
> 
> Funny, uh? If you have a SUN, replace "vax" with "sun".
> 

I gave up on cake also, but for different reasons..  I was trying to
use it to keep up with making sub-files: specifically, entries in
an archive.a. I never did get it to work. Finally decided that I
was understanding things correctly, but cake was broke.

Anyhow..

The example you gave demonstrates a problem with cpp, and cake
runs its input through cpp.  Try compiling the following C
one-liner on your vax:

  int vax;

I will not compile, because cpp translates it into

  int 1;

"vax" is predefined by cpp to be "1".

Oh well.  The reason they define sun, or vax, or whatever, is
for those #ifdef thingies, like

#ifdef sun
  some silly code
#else
  some other silly code
#endif sun

I can't think of any way to do it better, without drasticly changing
the way cpp works.  What's needed is some way to limit the scope of
#defines, so that the above could be done something like this:


#with <machine_type.h>
#  ifdef sun
      some silly code
#  else
      some other silly code
#  endif sun
#endwith <machine_type.h>

int sun;



But cpp was not specked very well to begin with, and
now we are pretty much stuck with it the way it is.



More information about the Comp.lang.c mailing list