Re: [Vala] workaround for assignment from incompatible pointer type

On Sat, Jul 10, 2010 at 02:29:16 +0000, James Moschou wrote:

I'm trying to subclass Clutter.Actor, I have:

public override void allocate (ActorBox box, AllocationFlags flags) {...

which generates:

static void text_view_real_allocate (ClutterActor* base, ClutterActorBox* box, 
ClutterAllocationFlags flags) {...

However at the line where this gets assigned to the class pointer, it has the 
error: "warning: assignment from incompatible pointer type".

That would be a bug. When vala accepts to compile something, it should not
generate these warnings.

I think because the class pointer is expecting a "const" in front of 
"ClutterActorBox *box".

No. Const can be added by assignment without any warnings. It can't be
removed, but the error would be different.

It's more likely the use of pointer to base vs. pointer to derived (since
C does not have inheritance, they are incompatible pointers for C compiler).

Can you please provide a simple test case where the problem appears? Report
a bug in bugzilla and attach the test there, please.

Is this known?

There appeared many cases where this warning was generated in the past. Some
of them were fixed, some may have not been. Check the bugzilla whether you'll
see similar-looking bug there. If yes, just add your test case, if no, open
new bug.

Is there a workaround?

You are not supposed to look at anything from the C compiler unless you are
binding C library for vala (writing a .vapi). So as long as it otherwise
works, disable C compiler warnings (you can tell valac to pass appropriate
options with '-X' (so e.g. '-X -w').

                                                 Jan 'Bulb' Hudec <bulb ucw cz>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]