🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.amiga.tech
6 messages
6 total messages Started by Frank McPherson Mon, 10 Dec 1990 19:03
Problem with OpenLibrary() under 2.0
#7341
Author: Frank McPherson
Date: Mon, 10 Dec 1990 19:03
30 lines
1557 bytes
I'm trying to play around with windows and such.  I've encountered an error
I can't figure out.  Here
is the stuff:

#include <exec/types.h>             
#include <intuition/intuition.h>    
                                    
struct IntuitionBase *IntuitionBase;
struct Window *Window;

void OpenLibrary();                            
                                               
if (!(IntuitionBase = (struct IntuitionBase *) 
   OpenLibrary("intuition.library")))          
 {                                             
 printf("Could not open intuition.library.\n");
 close_junk();                                 
 exit(FALSE);                                  
 }

This ain't working.  Manx 5.0d tells me that there's an invalid type conversion
in the if statement, right on the second close paren after the actual 
OpenLibrary() call.  I thought maybe it was that I was passing it an old 
version number (I was passing 0L as the version number right after the first
arguement), but taking it out didn't make a bit of difference.  What am I 
missing?
Thanks,

-- Frank McPherson                  INTERNET: fmcphers@vttcf.cc.vt.edu --
Re: Problem with OpenLibrary() under 2.0
#7359
Author: Brian Jackson
Date: Mon, 10 Dec 1990 22:53
56 lines
2455 bytes
In article <9012101903.AA146539@vttcf.cc.vt.edu> fmcphers@VTTCF.CC.VT.EDU (Frank McPherson) writes:
>
>I'm trying to play around with windows and such.  I've encountered an error
>I can't figure out.
>
>#include <exec/types.h>             
>#include <intuition/intuition.h>    
>struct IntuitionBase *IntuitionBase;
>void OpenLibrary();                            
>if (!(IntuitionBase = (struct IntuitionBase *) 
>   OpenLibrary("intuition.library")))            
> {                                             
> printf("Could not open intuition.library.\n");
> close_junk();                                 
> exit(FALSE);                                  
> }

>This ain't working.  Manx 5.0d tells me that there's an invalid type conversion
>in the if statement, right on the second close paren after the actual 
>OpenLibrary() call.  I thought maybe it was that I was passing it an old 
>version number (I was passing 0L as the version number right after the first
>arguement), but taking it out didn't make a bit of difference.  What am I 
>missing?
>Thanks,

You're missing the version number, as you mentioned, and the file
"functions.h" which tells the compiler a lot of things it needs to be
happy. This works:

#include<exec/types.h>
#include<intuition/intuition.h>
#include<functions.h>           /* Manx smiles on this file :) */

struct IntuitionBase *IntuitionBase ;

void main(void)
{
	if(IntuitionBase = OpenLibrary("intuition.library", 0L ))
	{
		printf("success\n") ;
		CloseLibrary( IntuitionBase ) ;
	}
	else
	{
		printf("failure\n") ;
	}
}

bj
		
>-- Frank McPherson                  INTERNET: fmcphers@vttcf.cc.vt.edu --

 -----------------------------------------------------------------------
 | Brian Jackson  Software Engineer, Commodore-Amiga Inc.  GEmie: B.J. |
 | bj@cbmvax.cbm.commodore.com    or  ...{uunet|rutgers}!cbmvax!bj     |
 |---------------------------------------------------------------------|
Re: Problem with OpenLibrary() under 2.0
#7362
Author: Narciso Jaramillo
Date: Tue, 11 Dec 1990 05:31
22 lines
1368 bytes
In article <9012101903.AA146539@vttcf.cc.vt.edu> fmcphers@VTTCF.CC.VT.EDU (Frank McPherson) writes:

> I'm trying to play around with windows and such.  I've encountered an error
> I can't figure out.  Here is the stuff:

> [...]
> void OpenLibrary();                            
  ^^^^
> if (!(IntuitionBase = (struct IntuitionBase *) 
>    OpenLibrary("intuition.library")))          
> [...]

> Manx 5.0d tells me that there's an invalid type conversion
> in the if statement, right on the second close paren after the actual 
> OpenLibrary() call.

You're declaring OpenLibrary() as void, then using its return value--strictly
a no-no.  It should be declared as struct Library *OpenLibrary().  Also, you
should put the 0L back in the call to OpenLibrary.


nj
Re: Problem with OpenLibrary() under 2.0
#7390
Author: Brian Jackson
Date: Tue, 11 Dec 1990 15:16
36 lines
1830 bytes
In article <NJ.90Dec10213112@magnolia.Berkeley.EDU> nj@magnolia.Berkeley.EDU (Narciso Jaramillo) writes:
>In article <9012101903.AA146539@vttcf.cc.vt.edu> fmcphers@VTTCF.CC.VT.EDU (Frank McPherson) writes:
>
>> [...]
>> void OpenLibrary();                            
>  ^^^^
>> if (!(IntuitionBase = (struct IntuitionBase *) 
>>    OpenLibrary("intuition.library")))          
>> [...]
>
>> Manx 5.0d tells me that there's an invalid type conversion
>> in the if statement, right on the second close paren after the actual 
>> OpenLibrary() call.
>
>You're declaring OpenLibrary() as void, then using its return value--strictly
>a no-no.  It should be declared as struct Library *OpenLibrary().  Also, you
>should put the 0L back in the call to OpenLibrary.
>
Well, yes and no. It should be

void *OpenLibrary() ;   /* a pointer to void */

This is ok as void pointers can be cast to/from other types (see page
199 of the ANSI K&R)
 
Manx 5.0 now defaults to 32-bits so the 0L is not required any more
(though still a good idea) - a simple '0' will do.

bj

>nj

 -----------------------------------------------------------------------
 | Brian Jackson  Software Engineer, Commodore-Amiga Inc.  GEnie: B.J. |
 | bj@cbmvax.cbm.commodore.com    or  ...{uunet|rutgers}!cbmvax!bj     |
 -----------------------------------------------------------------------
Re: Problem with OpenLibrary() under 2.0
#7404
Author: Ross Cunniff
Date: Tue, 11 Dec 1990 21:56
25 lines
1324 bytes
> void OpenLibrary();                            
  ^^^^ Umm, you definitely mean void *, or struct Library *, here.
                                               
> if (!(IntuitionBase = (struct IntuitionBase *) 
>    OpenLibrary("intuition.library")))          

> This ain't working.  Manx 5.0d tells me that there's an invalid type
> conversion
> in the if statement, right on the second close paren after the actual 
> OpenLibrary() call.  I thought maybe it was that I was passing it an old 
> version number (I was passing 0L as the version number right after the first
> arguement), but taking it out didn't make a bit of difference.  What am I 
> missing?

See above.

> Thanks,

You're welcome.

> -- Frank McPherson                  INTERNET: fmcphers@vttcf.cc.vt.edu --

				Ross Cunniff
				Hewlett-Packard Colorado Language Lab
				cunniff@hpfcla.HP.COM
Re: Problem with OpenLibrary() under 2.0
#7474
Author: Linda Seebach
Date: Sat, 15 Dec 1990 07:55
10 lines
1082 bytes
Folks: I had problems with this too.
Try OpenLibrary((UBYTE *)"foo.library"...)
The UBYTE * is an incompetence added by Manx. They insist that they have
to use special typedef'd names for all the data types. Note that the
library source for 5.0d won't even come *close* to compiling under 2.0.
anyway, strings are now unsigned char *'s... At least, that's the change
I always have to make to get the *#@!@$ compiler to shut up.
Anyone got a port of gcc? It would be so much easier... *grin*

--SeebS--
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