fmcphers@VTTCF.CC.VT.EDU (Frank McPherson) (12/11/90)
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 --
bj@cbmvax.commodore.com (Brian Jackson) (12/11/90)
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 | |---------------------------------------------------------------------|
nj@magnolia.Berkeley.EDU (Narciso Jaramillo) (12/11/90)
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
bj@cbmvax.commodore.com (Brian Jackson) (12/11/90)
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 | -----------------------------------------------------------------------
cunniff@hpfcso.HP.COM (Ross Cunniff) (12/12/90)
> 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
mndaily@ux.acs.umn.edu (Linda Seebach) (12/15/90)
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--