Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: iamaboringperson on January 28, 2003, 04:36:16 PM
-
do any of you know of any typeos(?) in the ARKRM: Devices?
virtually whenever i try to open/close a device i get so many compiler errors!
is this example from page 89 of the 3rd edition correct?
struct MsgPort *GameMP;
struct IOStdReq *GameIO;
if(!(GameMP=CreatePort("RKM_game_port",0)))
cleanexit();
if(!(GameIO=CreateExtIO(GameMP,sizeof(struct IOStdReq))))
cleanexit();
if(error=OpenDevice("gameport.device",1,GameIO,0))
cleanexit();
i get pretty much the same problems with other chapters
could sombody plese give me an example as to how a device should be opened and closed?
somthing simple all in the main function?
:-)
-
Looks ok to me. Did you #include clib/alib_protos.h and clib/exec_protos.h ? If so, look into the prototypes and do type casting for mismatching types. I guess that OpenDevice() takes an IORequest rather than an IOStdReq. Also post the error messages. I guess there are only warnings.
Bye,
Thomas
-
probably #include clib/alib_protos.h
i did get MANY errors!
ill take a look, and comeback with the errors later!
:-)
-
iamaboringperson wrote:
probably #include clib/alib_protos.h
i did get MANY errors!
ill take a look, and comeback with the errors later!
:-)
You sure that shouldn't have been #include ?
I realise that's probably just a typo in your post. I'll have a look at it when I have a mo. I havent got round to implementing gameport code in my existing work just yet but avoiding potential problems in advance always worth the effort..
Oh, a handy hint when dealing with the amiga's IO stuff is to define a union of IO pointer types for use with all the different IO functions. It saves lots and lots of casting which is often a source of silly compiler errors...
-
Karlos wrote:
iamaboringperson wrote:
probably #include clib/alib_protos.h
i did get MANY errors!
ill take a look, and comeback with the errors later!
:-)
You sure that shouldn't have been #include ?
I realise that's probably just a typo in your post. I'll have a look at it when I have a mo. I havent got round to implementing gameport code in my existing work just yet but avoiding potential problems in advance always worth the effort..
Oh, a handy hint when dealing with the amiga's IO stuff is to define a union of IO pointer types for use with all the different IO functions. It saves lots and lots of casting which is often a source of silly compiler errors...
heheh, that was a typo!
and i did have
still getting errors though :-(
so does anybody have a solution for any kind of device?
just somthing simple?
-
Hi there Iamaboringperson,
Can you please list the error messages you are getting so we can see what is going on. I'm curious to see what they are.
-
Steady wrote:
Hi there Iamaboringperson,
Can you please list the error messages you are getting so we can see what is going on. I'm curious to see what they are.
ok, ive been using Storm C V3, i was mucking around to try and get it working, i realised i couldnt easily output the errors straight into a file, so i switched to Lattice C(SAS/C), and guess what? no errors! LC has no problems with that part of the code! so im guessing its either Storm/C's fault, or, a problem with the includes! but the includes i use for storm C, and lattice C are virtually the same, not in the same directory, but the same source
but i would still prefer to use Sorm C, so here is whats wrong in a bit more detail:
NO linker errors!
no problems with includes not found
virtually anywhere GameIO, is found as an argument for a function there is an Illigal Argument Error! and my code is basically the same as in my previous post
its also basically the same as another piece of example code from the developer CD
so i dont know what the hell is going on? :-?
any help? :-? :-? :-? :-? :-?
-
I had a quick play and think I've found the source of your problem. It is basically as Karlos pointed out earlier. Casting is your problem.
amiga.lib's CreateExtIO function is expecting to return an IORequest pointer. You are expecting an IOStdReq pointer.
exec.library's OpenDevice function is causing the same problem for you, but in reverse. You should cast as follows assuming your variables are still defined in the same way:
if(!(GameMP=CreatePort("RKM_game_port",0)))
cleanexit();
if(!(GameIO=(struct IOStdReq *)CreateExtIO(GameMP,sizeof(struct IOStdReq))))
cleanexit();
if(error=OpenDevice("gameport.device",1,(struct IORequest *)GameIO,0))
cleanexit();
Hope that helps.
-
@Steady
i had a bit of a go with casting for SOME of it, but it was getting too frustrating! i thought it shouldnt need it, so i gave up :-( it was too frustrating to be mucking around with for all that time, and i couldnt think!
but thanks!! ill try that out!
:-) :-) :-) :-) :-)
i discoverd last night that the example program "absolute_joystick.c" came up with the same errors, so probably for the same reason
-
Since you are using StormC V3, I guess you´ll have the dev. CD. All example code on the dev. CD, has been adjusted to compile with StormC V3. Therefore you should load the example code directly from the CD instead of typing it in...
-
Hardboy wrote:
Since you are using StormC V3, I guess you´ll have the dev. CD. All example code on the dev. CD, has been adjusted to compile with StormC V3. Therefore you should load the example code directly from the CD instead of typing it in...
thats where it came from :-)
i didnt type it in!
my includes did come of the CD, but i think it might be more to do with storm c, since the ones i use for lattice c are from the same source
-
@Steady
no, i dont think its casting anymore :-(
i tried some of your casting aswell as alot of mine, still errors! basically the same errors, i think they were exactly the same :-(
perhaps its the configuration
or perhaps i should be using the includes that came with Storm C?
Storm C users: do you use the includes of the Dev CD? all of them? or some or all of the Storm C includes(assuming it has any)
i might reinstall, reconfigure, and if all that fails ill pick up my A4000T, carfuly and gently lift it up over my shoulders, and throw it against the wall!!
:-x :-x :-x :-x
-
That should be #include and for compatibility with all compilers.
-
@Iamaboringperson
Well, I loaded the code in StormC V3 with the 3.9 includes and received the errors you mentioned. The compiler is correct to point out these errors, although some are less tolerant. When I added the casting all errors went away. I know it is a pain, but I think the errors have to be seen to get any further.
-
ncafferkey wrote:
That should be #include and for compatibility with all compilers.
i suppose before i destroy my beloved A4000T, ill try that too!
:-(
-
Steady wrote:
I had a quick play and think I've found the source of your problem. It is basically as Karlos pointed out earlier. Casting is your problem.
amiga.lib's CreateExtIO function is expecting to return an IORequest pointer. You are expecting an IOStdReq pointer.
exec.library's OpenDevice function is causing the same problem for you, but in reverse. You should cast as follows assuming your variables are still defined in the same way:
if(!(GameMP=CreatePort("RKM_game_port",0)))
cleanexit();
if(!(GameIO=(struct IOStdReq *)CreateExtIO(GameMP,sizeof(struct IOStdReq))))
cleanexit();
if(error=OpenDevice("gameport.device",1,(struct IORequest *)GameIO,0))
cleanexit();
Hope that helps.
ok, thanks steady! after much #### ing around, i just ripped my code out stuck yours in, and it worked
but now i have another problem, which is the same thing i had a year ago when i was trying to use "keyboard.device"
it opens ok, but when it finaly flushes and closes the thing, the whole machine crashes, ive tried to use storms debug modes, but the machine will only crash
ill try to get the code here soon if that will help, but its basically whats found in the ARKRMs, except with the extra casting stuck in
:-)
last time with the keyboard stuff, i just commented-out the device close bits and exited the program without any of that clean up!! :-o
but this time i want to do things properly of course