ThinkC program--why wont it work?

joseph.a.brownlee jbr0 at cbnews.att.com
Thu Mar 7 22:39:46 AEST 1991


In article <91064.120155EAO102 at psuvm.psu.edu> EAO102 at psuvm.psu.edu (Ernie
Oporto) writes:
> I have entered this program into Think C for compilation.  It appeared in the
> C Users Journal in the August 1990 issue.  When I try to compile it, I get
> "t_window ..." and "t_windinfo not defined".

That's because they aren't defined.

>                                              What should I do.

Define them.

> [...]
>
>/*** text window creation function ***/
>
>void create_t_window(title,wrect,closebox)
>char *title;
>Rect wrect;
>int closebox;
>{
>/*    ...     */

       ^^^ See that?  They are telling you they left stuff out.  You need to
define t_window and t_windinfo here.  You can easily determine the types from
the following code:

>
>/* allocate new window info */
>
>   t_windinfo = (WIND *)NewPtr(sizeof(WIND));
>
>/* allocate new window */
>
>   t_window = NewWindow(NIL,&wrect,title,TRUE,8,FRONT,closebox,NIL);

The correct definitions are:

	WIND *		t_windinfo;
	WindowPtr	t_window;

Note also that by using "NIL" as your first argument, you are not allocating
space to store the window record.  This will often work, but you then risk
heap problems.  It is very easy to allocate the storage yourself; see Inside
Macintosh I (Window Manager) for details.

In general, I hate examples that leave out definitions.  Novices are bound
to be confused by stuff like this, and they're the ones most likely to be
looking for examples.

-- 
   -      _   Joe Brownlee, Analysts International Corp. @ AT&T Network Systems
  /_\  @ / `  471 E Broad St, Suite 1610, Columbus, Ohio 43215   (614) 860-7461
 /   \ | \_,  E-mail: jbr at cblph.att.com     Who pays attention to what _I_ say?
 "Scotty, we need warp drive in 3 minutes or we're all dead!" --- James T. Kirk



More information about the Comp.lang.c mailing list