farmer@ecs.umass.edu (THE MAD MUSKRAT) (06/14/91)
Hi, I am trying to work with the Toolbox in Think C and having trouble with polygons. I am trying to load a number of polygons from a resource (actually, load the points and doing LineTo's to make polygons). The problem is this: In Quickdraw.h the pascal function OpenPoly is defined, but the rest of the polygon functions aren't. I realize that openpoly is the only function that returns a value, but the other functions won't work. If I use ClosePoly to end the polygon definition I get a compiler error: Invalid use of inline function. What does that mean?? The code looks like: void LoadLevel (level, theWell) int level; PolyHandle theWell[]; { int notDone = 1; Handle res; res = GetResource ('LEVL', level); if (!res) exit(1); for (segments=0; notDone; segments++) { theWell[segments] = OpenPoly(); MoveTo(*(*res+(8*segments)),*(*res+(8*segments+1))); LineTo(*(*res+(8*segments+2)),*(*res+(8*segments+3))); LineTo(*(*res+(8*segments+4)),*(*res+(8*segments+5))); LineTo(*(*res+(8*segments+6)),*(*res+(8*segments+7))); ClosePoly; if (*(*res+(8*segments+4)) == 0 && *(*res+(8*segments+5)) == 0) notDone=0; }; } Anyone who cares to give me a hint is welcome (yes, I know the programming style is slightly crude, but it is a first shot at C). thanks, Matt Farmer ---------------------------------------------------------------------- internet: farmer@ecs.umass.edu farmer@saturn.ucc.umass.edu
mullerd@prism.cs.orst.edu (Douglas Muller) (06/14/91)
In article <13974.2857e2a1@ecs.umass.edu> farmer@ecs.umass.edu (THE MAD MUSKRAT) writes: >In Quickdraw.h the pascal function OpenPoly is defined, but the rest of the >polygon functions aren't. I realize that openpoly is the only function that >returns a value, but the other functions won't work. If I use ClosePoly to >end the polygon definition I get a compiler error: Invalid use of inline >function. What does that mean?? > >The code looks like: > >void LoadLevel (level, theWell) >int level; >PolyHandle theWell[]; >{ >int notDone = 1; >Handle res; >res = GetResource ('LEVL', level); >if (!res) exit(1); >for (segments=0; notDone; segments++) { > theWell[segments] = OpenPoly(); > MoveTo(*(*res+(8*segments)),*(*res+(8*segments+1))); > LineTo(*(*res+(8*segments+2)),*(*res+(8*segments+3))); > LineTo(*(*res+(8*segments+4)),*(*res+(8*segments+5))); > LineTo(*(*res+(8*segments+6)),*(*res+(8*segments+7))); > ClosePoly; > if (*(*res+(8*segments+4)) == 0 && *(*res+(8*segments+5)) == 0) notDone=0; > }; >} > I Don't know much about polygons but I do know that if you don't LOCK the handle to that resource you will be in big trouble. res = GetResource(...); hState = HGetState(res); HLock(res); your code HSetState(res, hState); I guaranty that it won't HURT! Stephen Roderick mullerd@prism.cs.orst.edu
gmarzot@mitre.org (G. S. Marzot (Joe)) (06/15/91)
> In article <13974.2857e2a1@ecs.umass.edu> farmer@ecs.umass.edu (THE MAD MUSKRAT) writes: > >In Quickdraw.h the pascal function OpenPoly is defined, but the rest of the > >polygon functions aren't. I realize that openpoly is the only function that > >returns a value, but the other functions won't work. If I use ClosePoly to > >end the polygon definition I get a compiler error: Invalid use of inline > >function. What does that mean?? > > > >The code looks like: > > > >void LoadLevel (level, theWell) > >int level; > >PolyHandle theWell[]; > >{ > >int notDone = 1; > >Handle res; > >res = GetResource ('LEVL', level); > >if (!res) exit(1); > >for (segments=0; notDone; segments++) { > > theWell[segments] = OpenPoly(); > > MoveTo(*(*res+(8*segments)),*(*res+(8*segments+1))); > > LineTo(*(*res+(8*segments+2)),*(*res+(8*segments+3))); > > LineTo(*(*res+(8*segments+4)),*(*res+(8*segments+5))); > > LineTo(*(*res+(8*segments+6)),*(*res+(8*segments+7))); > > ClosePoly; > > if (*(*res+(8*segments+4)) == 0 && *(*res+(8*segments+5)) == 0) notDone=0; > > }; > >} this is a little embarassing but how about "ClosePoly();" instead of "ClosePoly;" -gsm ex-pascal programmers unite! Email: gmarzot@linus.mitre.org (standard disclaimer)
d88-jwa@byse.nada.kth.se (Jon W{tte) (06/15/91)
> ClosePoly; > Illegal use of inline function You can't take the address of an inline function (such as ClosePoly) What you _want_ to do is call it, so ClosePoly() is the way to go. I explained this in a little more detail to the original poster... -- Jon W{tte h+@nada.kth.se - Speed !
dorner@pequod.cso.uiuc.edu (Steve Dorner) (06/15/91)
Douglas Muller writes: >THE MAD MUSKRAT writes: >>returns a value, but the other functions won't work. If I use ClosePoly to >>end the polygon definition I get a compiler error: Invalid use of inline >>function. What does that mean?? >> ClosePoly; It means you want to say "ClosePoly();"--you ALWAYS must use ()'s in a C function call, even if there are no arguments. >> LineTo(*(*res+(8*segments+6)),*(*res+(8*segments+7))); >I Don't know much about polygons but I do know that if you don't >LOCK the handle to that resource you will be in big trouble. Bzzzzt. Wrong answer. There's no need to lock the handle, as it's being used quite safely. Now, I'm a bit confused by all the pointer math, but the water rodent could save itself a lot of work by reading up on using [] with pointers. A judicious declaration of "res" could hide a lot of the complexity. (Yes, the large aquatic rat said it was a beginner, and I'm not flaming; just suggesting...) -- Steve Dorner, U of Illinois Computing Services Office Internet: s-dorner@uiuc.edu UUCP: uunet!uiucuxc!uiuc.edu!s-dorner
glenn@gla-aux.uucp (Glenn Austin) (06/15/91)
In article <13974.2857e2a1@ecs.umass.edu>, farmer@ecs.umass.edu (THE MAD MUSKRAT) writes: > In Quickdraw.h the pascal function OpenPoly is defined, but the rest of the > polygon functions aren't. I realize that openpoly is the only function that > returns a value, but the other functions won't work. If I use ClosePoly to > end the polygon definition I get a compiler error: Invalid use of inline > function. What does that mean?? > > The code looks like: > > void LoadLevel (level, theWell) > int level; > PolyHandle theWell[]; > { > int notDone = 1; > Handle res; > res = GetResource ('LEVL', level); > if (!res) exit(1); > for (segments=0; notDone; segments++) { > theWell[segments] = OpenPoly(); > MoveTo(*(*res+(8*segments)),*(*res+(8*segments+1))); > LineTo(*(*res+(8*segments+2)),*(*res+(8*segments+3))); > LineTo(*(*res+(8*segments+4)),*(*res+(8*segments+5))); > LineTo(*(*res+(8*segments+6)),*(*res+(8*segments+7))); > ClosePoly; ^^^^^^^^^ Syntax Error: Missing parens (). Attempted to use function address as ?. Why couldn't they have simply said that the function parens are missing? =============================================================================== | Glenn L. Austin | "Turn too soon, run out of room. | | Macintosh Wizard and | Turn too late, much better fate." | | Auto Racing Driver | -- Jim Russell Racing School Instructors | |-----------------------------------------------------------------------------| | Don't take me too seriously -- I never do! :-) | |-----------------------------------------------------------------------------| | Usenet: glenn@gla-aux.uucp or glenn%gla-aux.uucp@skinner.cs.uoregon.edu | ===============================================================================
sho@gibbs.physics.purdue.edu (Sho Kuwamoto) (06/15/91)
In article <eep> glenn%gla-aux.uucp@skinner.cs.uoregon.edu writes: >In article <gack>, farmer@ecs.umass.edu (THE MAD MUSKRAT) writes: >> I get a compiler error: Invalid use of inline function. [...] >> ClosePoly; > ^^^^^^^^^ >Why couldn't they have simply said that the function parens are missing? The statement, as typed, asks the compiler to take the address of the function and do nothing with it. THINK C should issue a warning (something to the effect of, "That line does absolutely nothing. Are you sure you don't want parentheses?"), but THINK C never issues warnings. In this case, the function has no address, so the compiler chokes. The error message might be better if it read, "You can't take the address of an inline function," but it would probably still be confusing unless you knew what an inline function was. -Sho -- sho@physics.purdue.edu
dorner@pequod.cso.uiuc.edu (Steve Dorner) (06/17/91)
In article <0E010021.a2n8ad@gla-aux.uucp> glenn%gla-aux.uucp@skinner.cs.uoregon.edu writes: >> ClosePoly; > ^^^^^^^^^ >Why couldn't they have simply said that the function parens are missing? A function name without the parens is a legal expression (it's the address of the function), and a legal expression is a legal statement. "2;" is a legal statement, f'rinstance. The only problem here is that, ClosePoly being inline, there's no way to take its address. -- Steve Dorner, U of Illinois Computing Services Office Internet: s-dorner@uiuc.edu UUCP: uunet!uiucuxc!uiuc.edu!s-dorner