Page 1 of 1

Wrong typecast in GetApplicationAttrs() autodoc?

Posted: Sun Jan 27, 2013 12:11 pm
by trixie
I see that the autodoc for GetApplicationAttrs() / GetApplicationAttrsA() contains the following example code:

Code: Select all

       struct MsgPort *port;

       if (GetApplicationAttrs(appID, APPATTR_Port, (uint32)&port, TAG_DONE))
       {
           ... receive messages ...
       }
But surely the typecast is wrong? Assuming that the function uses the same type of storage as Intuition's GetAttrs(), I guess the line should read:

if (GetApplicationAttrs(appID, APPATTR_Port, (uint32 *)&port, TAG_DONE))

Re: Wrong typecast in GetApplicationAttrs() autodoc?

Posted: Sun Jan 27, 2013 3:43 pm
by salass00
@trixie

It's defined as a varargs function so no cast should be necessary unlike with GetAttr() where the type of the storage pointer is defined in the function definition.

Re: Wrong typecast in GetApplicationAttrs() autodoc?

Posted: Mon Jan 28, 2013 6:50 pm
by ssolie
As salass00 already pointed out, type casting with varargs is quite irrelevant. Removing the type cast completely is the correct fix.

Re: Wrong typecast in GetApplicationAttrs() autodoc?

Posted: Tue Jan 29, 2013 11:54 am
by Hans-Joerg Frieden
The typecasting is pretty much irrelevant, that's true. However, Trixie has a point here, it's bad style because it will produce code that is not 64 bit clean. Not that we run on any 64 bit target, but then, there is no need to artificially create these issues :)