Thread View: comp.sys.amiga.tech
1 messages
1 total messages
Started by Lamonte Koop
Tue, 29 Jan 1991 07:16
Re: Help with Simple Screen Program
Author: Lamonte Koop
Date: Tue, 29 Jan 1991 07:16
Date: Tue, 29 Jan 1991 07:16
74 lines
3320 bytes
3320 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads