jp48+@andrew.cmu.edu (Jonathan Pace) (02/24/91)
I'm working my way through the "Macintosh C Programming Primer" and I've bombed on the Hello, World #2 program. I get the error "invalid declaration" when I precompile. The offending line seems to be: WindowPtr gHelloWindow; I'm clueless. Help, please. Jon Pace
Louis.Pecora@f421.n109.z1.fidonet.org (Louis Pecora) (02/25/91)
Did you #include "Windows.h" ? That's probably where WindowPtr is defined. You probably want to include all the Mac header files at first until you learn what each is for. Are you using Think C or MPW C. They're similiar, but there are some things in the "Macintosh C Programming Primer" that could lead you astray (it's dependent on Think C), although it is a great primer. --- Lou Pecora -- Louis Pecora, Louis.Pecora@f421.n109.z1.fidonet.org via The Black Cat's Shack's FidoNet<->Usenet Gateway blkcat.fidonet.org and Fidonet 1:109/401
john@newave.UUCP (John A. Weeks III) (02/26/91)
In article <0blpRGq00WB34DLlpM@andrew.cmu.edu> jp48+@andrew.cmu.edu (Jonathan Pace) writes: > I'm working my way through the "Macintosh C Programming Primer" and I've > bombed on the Hello, World #2 program. I get the error "invalid declaration" > when I precompile. The offending line seems to be: > WindowPtr gHelloWindow; I typed it in, and other than converting the rest of the program to Standard-C, it worked OK on Think C 4.0. Since it is short, try retyping the file. Otherwise, select the line before through the line after the offending line and delete it. Sometimes "hidden characters" can get into you file. At any rate, here is my file hello.c: ---CUT-HERE--- WindowPtr gHelloWindow; void ToolBoxInit( void ) { InitGraf( &thePort ); InitFonts(); FlushEvents( everyEvent, 0 ); InitWindows(); InitMenus(); TEInit(); InitDialogs( 0L ); InitCursor(); } void WindowInit( void ) { gHelloWindow = GetNewWindow( 400, 0L, -1L ); ShowWindow( gHelloWindow ); SetPort( gHelloWindow ); MoveTo( 30, 50 ); DrawString( "\pHello, World" ); } void main( void ) { ToolBoxInit(); WindowInit(); while( !Button() ) ; } ---CUT-HERE--- -john- -- =============================================================================== John A. Weeks III (612) 942-6969 john@newave.mn.org NeWave Communications ...uunet!rosevax!tcnet!wd0gol!newave!john ===============================================================================
egw.weakm@p3.lanl.gov (Eric Wasserman) (02/27/91)
In article <669@newave.UUCP> john@newave.UUCP (John A. Weeks III) writes: >I'm working my way through the "Macintosh C Programming Primer" and I've >bombed on the Hello, World #2 program. I get the error "invalid declaration" >when I precompile. The offending line seems to be: ^^^^^^^^^^ > > WindowPtr gHelloWindow; You aren't really trying to 'PREcompile' a .c file are you? Precompile is a special ThinkC speedup feature which you probably shouldn't worry about using until you get yourself oriented in the ThinkC environment. Try plainold "Compile". Sorry if this was just a typo on your part. Eric egw.weakm@p3.lanl.gov