Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!glyph!ahh From: ahh@glyph.kingston.ny.us (Andy Heffernan) Newsgroups: comp.sys.amiga.programmer Subject: Re: Why does this GURU??? Message-ID: <1606@glyph.kingston.ny.us> Date: 23 Jun 91 00:41:49 GMT References: <1991Jun13.113948.3806@fwi.uva.nl> Reply-To: ahh@glyph.UUCP (Andy Heffernan) Organization: Moji Computing Lines: 55 In article <1991Jun13.113948.3806@fwi.uva.nl> bosman@fwi.uva.nl (Dr.D) writes: >I have here a little program (small part of a larger one) that >gurus. But I can't figure out why.. > >Maybe some of you guys see what I do wrong.. >it gurus at the WritePixel..... You've gotten your answer already, but I wanted to point out that you're playing silly buggers with pointers, and that some day all of your code will start to fail, violently. >struct Screen *Scrn; Now, Scrn is a pointer. > Scrn = (struct Screen *)make_screen(y,w,h,d,c0,c1,mode,"TESTSCREEN"); Scrn is being set to whatever thing make_screen returns, but is coerced into a pointer, perhaps to keep the compiler from complaining. Hmmm, this looks suspicious. What does make_screen return? >make_screen(y,w,h,d,color0,color1,mode,name) >SHORT y,w,h,d; >UBYTE color0,color1,*name; >USHORT mode; make_screen returns an int. Pointers and ints are not the same thing. You need a pointer, therefore make_screen (and by extension OpenScreen) should return pointers. OpenScreen does already, that's the way it was written. You must declare it correctly, however, before it is used. The same holds for make_screen as well, except that you must also define it correctly. The right thing to do is: struct Screen *Scrn; struct Screen *OpenScreen(); struct Screen *make_screen(); ... much code ... Scrn = make_screen(y,w,h,d,c0,c1,mode,"TESTSCREEN"); ... much code ... struct Screen *make_screen(y,w,h,d,color0,color1,mode,name) SHORT y,w,h,d; UBYTE color0,color1,*name; USHORT mode; ... everything else ... Do the same thing with your window variable and code. -- ------------------------------------------------------------------------- Andy Heffernan $BJ8;z(J uunet!glyph!ahh