[net.micro.amiga] Trouble with new Mandelbrot program & and Bug in Lattice C 3.02

cosell@BBN-PROPHET.ARPA (01/13/86)

From: Bernie Cosell <cosell@BBN-PROPHET.ARPA>

I got the new, more-fancy-than-you-can-believe version of 'mand' up and
running last night.  There were a couple of things you should look out for:
    a) It sets up a library as an "IconBase *".  That structure isn't
       defined anywhere, but if you just ignore the warning all is well.
    b) As promised in the official bug list, enumerated data types don't
       work and so the enum in workbench/workbench.h makes the compiler
       belly up and die.  I edited the enum (WBObject, I think) to be
       a typedef to an int, and the #define'd all of the enum values.
       You then have to go through the rest of that file and change all
       of the "enum WBObject"s to be just "WBObject".
    c) Although I didn't see any bug reported that bit fields don't work,
       I kept getting diatnostics on (again) workbench/workbench.h
       about illegal fields.  So I just commented out all of the 
       UWORD ...:1;'s and put in a single "UBYTE WB_JUNK" to try to keep
       the size of the struct and the field alignment OK.  Seemed to work.

With those changes, the whole thing compiled up and seems to run fine.
I did notice, though, that the presets didn't work: If I just typed "G"
when the program started, I got an all-black screen.  Some poking revealed
the problem.  In SetPresets (in mand.c), the code reads (correctly):
         start_r.f = -2.85;
         end_r.f = 2.85;
         start_i.f = -2.05;
         end_i.f = 2.05;
Well ***THE C COMPILER MISCOMPILES THIS SEQUENCE OF STATEMENTS!!!***
All four variables end up getting set to -2.85!!!  I tried a very
simple test program:
    main ()
    {
        float f;
 
        f = 1.5;
        printf ("%f (%f)\n", f, 1.5);
        f = 2.5;
        printf ("%f (%f)\n", f, 2.5);
    }
The output is, unbelievably enough,
      1.5 (1.5)
      1.5 (2.5)
I tried and tried and couldn't get the compiler to do the successive
floating assignments correctly.  I fixed this eventually by adding
a function to mand.c:
   fl_assign (var, val)
      float *var, val;
   {   *var = val; }

and then I changed every assignment in SetPresets from
things like
     start_i.f = -0.169450;  to be  fl_assign (&start_i.f, -0.169450)

If you do this, the assignments work correctly and your presets will
work.  If anyone knows more about what this bug really is or if there is
a less brutish way to finesse it, I'd be interested to hear about it.

   /Bernie

ps, Thanks RJ!!!!!  In addition to being a very neat program, it is,
as you said, a veritable GOLD MINE of examples of how to do very fancy
things with Intuition.  There is a lot of studying and learning to be
done!!  /b

pps, Why *are* the colors ordered GRB instead of RGB??  /b

farren@well.UUCP (Mike Farren) (01/14/86)

In article <964@caip.RUTGERS.EDU>, cosell@BBN-PROPHET.ARPA writes:
>     b) As promised in the official bug list, enumerated data types don't
>        work...

     Which answers my complaint neatly, and points out the benefits to be
had from reading the documentation...  Sigh.


-- 
           Mike Farren
           uucp: {your favorite backbone site}!hplabs!well!farren
           Fido: Sci-Fido, Fidonode 125/84, (415)655-0667