TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: all
from: GLEN HATHAWAY 71446,166
date: 1993-02-03 21:56:02
subject: #struct pointer trouble

#: 17473 S3/Languages
    03-Feb-93  21:56:02
Sb: #struct pointer trouble
Fm: GLEN HATHAWAY 71446,166
To: all

 Hi all... I'm playing with a C function to do graphic fills. I'm using an
algorithm (and code) from Graphics Gems (edited by Andrew S. Glassner. I'm
getting lots of errors from the linker like this:

     *** error - value out of range ***
     00042   move.l 80028(sp),d1

 Here are the pertinent parts of the code:

     typedef struct{short y, xl, xr, dy;} segment

     #define MAX 10000

     #define PUSH(Y, XL, XR, DY) \
         if(sp=0 && Y+(DY)<=maxx) \
         {sp->y=Y; sp->xl=XL; sp->xr=XR; sp->dy=DY; sp++;}

     #define POP(Y,XL,XR,DY) \
         {sp--; Y=sp->y+(DY=sp->dy); XL=sp->xl; XR=sp->xr;}

     fill(x,y,nv)
     int x,y,nv;
     {
         segment stack[MAX], *sp=stack;

         PUSH(y,x,x,1);
         PUSH(y+1,x,x,-1);
         .
         .
         .
         POP(y,x1,x2,1);
         etc.....
     }

 Looks to me like it defines an array of 10000 copies of struct segment, then
defines a pointer (sp) of type 'segment' to the structures to allow variables
to be stacked and unstacked 4 at a time.

 Anybody know how to make this work on my MM/1. I'm not enough of a C guru to
solve it (so far).

 Thanks in advance. Glen Hathaway - COMPER - 71446,166

There is 1 Reply.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.