Page 1 of 1

__USE_INLINE__

Posted: Thu Aug 11, 2011 9:38 am
by JosDuchIt
The OS3 BOOPSI example RKMButClass.c, i worked on,now compiles and works under OS4
I am now trying to get rid of pointer warnings
I do use
#define __USE_INLINE__

So in 'main' i have

struct Gadget *integer, *but;
if (integer = (struct Gadget *)NewObject(NULL,
"strgclass",
GA_ID, 1L,
; ....
TAG_END))
{
if (but = (struct Gadget *)NewObject(rkmbutcl,
...
{

and at cleanup:

DisposeObject(but);
DisposeObject(integer);

I get the warning: passing argument 2 of 'IIntuition->DisposeObject' from incompatible pointer type
for both lines

Looking into the file RKMButClass.e
produced using gcc's -E option
i find the same declarations for but and integer
and the follosing 'Dispose' lines
IIntuition->DisposeObject((but));
IIntuition->DisposeObject((integer));


In the autodoc i found
----

intuition.library/DisposeObject intuition.library/DisposeObject
void DisposeObject(Object *obj);
INPUTS
obj - abstract pointer to a BOOPSI object returned by NewObject().
NAME
}
----
So i tried a cast


DisposeObject((struct Object *)but);
DisposeObject((struct Object *)integer);

Those lines were transformed in the .e file to

IIntuition->DisposeObject(((struct Object *)but));
IIntuition->DisposeObject(((struct Object *)integer));

but i still have exactly the same warnings.

Is it possible at all using the __USE_INLINE__ define and corresponding macro's to avoid those warnings?

Re: __USE_INLINE__

Posted: Thu Aug 11, 2011 2:37 pm
by trixie
DisposeObject((struct Object *)but);
DisposeObject((struct Object *)integer);
There is no "struct Object", there is only Object!

As of the latest OS4 SDK, all BOOPSI gadgets and images are to be declared as a pointer to Object, not struct Gadget or Image, respectively. So try something like this:

Object *integer, *but;
if (integer = NewObject(NULL,
"strgclass",
GA_ID, 1L,
; ....
TAG_END))
{
if (but = NewObject(rkmbutcl,
...

If a specific function - like SetGadgetAttrs() - expects a pointer to struct Gadget (instead of an Object), you need to cast:

SetGadgetAttrs( (struct Gadget *) but, window, NULL, ... TAG_END);

Re: __USE_INLINE__

Posted: Fri Aug 12, 2011 9:50 am
by JosDuchIt
Thanks Trixie,

The source now compiles without warnings.
I uploaded it here
http://users.online.be/AD/C_Boopsi_RKMButClass.c

I had still to do some more adaptions:

make more explicit declarations:

struct Gadget *integer, *but;
Object *integero, *buto;
struct Message *msgm;
struct IntuiMessage *msgi;

where
but = (struct Gadget *)buto;
integer = (struct Gadget *)integero;

and also
struct Message *msgm;
struct IntuiMessage *msgi;
with appropriate cast :
msgi = (struct IntuiMessage *)msgm;


I also made use of the general layout you used in your Reaction example

Re: __USE_INLINE__

Posted: Fri Aug 12, 2011 10:59 am
by trixie
@JosDuchIt

Thanks. The example might entice me to write a custom ReAction class - something I wanted to try out for quite some time.