Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jarthur!petunia!ucselx!crash!pnet01!lkoop From: lkoop@pnet01.cts.com (Lamonte Koop) Newsgroups: comp.sys.amiga.tech Subject: Re: Help with Simple Screen Program Message-ID: <7277@crash.cts.com> Date: 29 Jan 91 07:16:01 GMT Sender: root@crash.cts.com Organization: People-Net [pnet01], El Cajon CA Lines: 74 874226@watt.usask.ca (Shawn Switenky) writes: >Hello All, > I need help. I'm learnig both C and Amiga specific programming at >the same time. I've been trying to get the following program working. All >it does is create a window on a custom screen, and ten wiat for you to click >on the close button. Simple, right? > What it actally does is hang. It give me a requester then says: >Software Failed >Error number #80000004 > It compiles and links without any errors or warnings. When I run it, >it hangs. I'm using SAS C 5.10a under Workbench 2.02 and using the 2.0 >version of includes. > When I run CodeProbe on it, it hangs after the line: >if (IntuitionBase == NULL) exit(1); > and I have to reboot the machine. > > I believe I am not successful in opening up the intuition.library, and >it could be because of the version number. I'm using old documentation ( V1.1 Yes, your problem is in the opening of intuition.library. Read on: >#include "exec/types.h" >#include "intuition/intuition.h" >#include "stdlib.h" > >struct IntuitionBase *IntuitionBase; >struct GfxBase *GfxBase; > >struct Screen *CustScr; >struct Window *Wdw; >struct ViewPort *WVP; [some stuff deleted] > >void main(void) >{ > /* Open the Intuition and Graphics Libraries, */ > /* Get pointers to the routines */ > > IntuitionBase = (struct IntuitionBase *) > OpenLibrary("intuition.library",36); > if ( IntuitionBase == NULL ) exit(1); > > GfxBase = (struct GfxBase *) > OpenLibrary("graphics.library",36); > if ( GfxBase == NULL ) exit(1); In order not to limit yourself to the version number (unless it is important), use 0L for the version number. This is an "I don't care" number saying "Just open intuition.library, whatever the version". Remember, the version numbers are long values, hence 0L. Also, it's common to shorten a statement such as yours with the "not" operator ('!'), such as: if(!(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",0L))) exit(1); This is valid as any zero value is considered "false" in C. Also, IntuitionBase and GfxBase should be declared as extern such: extern struct IntuitionBase *IntuitionBase; extern struct GfxBase *GfxBase; as they are variables pulled in with the startup code. Now, if you are not using the standard startup code, then your declaration is perfectly fine. LaMonte Koop Internet: lkoop@pnet01.cts.com ARPA: crash!pnet01!lkoop@nosc.mil UUCP: {hplabs!hp-sdd ucsd nosc}!crash!pnet01!lkoop A scientist is one who finds interest in the kinetic energy of Jell-O moving at ridiculous velocities...an engineer is one who can find a real-life application for such silliness.