lua-users home
lua-l archive

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


On Saturday, 23 April 2011, liam mail <liam.list@googlemail.com> wrote:
> On Saturday, 23 April 2011, Patrick Rapin <toupie300@gmail.com> wrote:
>>> Input makes illegal casts from a void pointer to a function pointer and vice
>>> versa,
>>
>> I didn't know this was illegal. Are there any generic type to which
>> one can legally cast
>> a pointer to a function? Anyway, in this case, I added lua_CFunction
>> to the union.
>>
>
> A C function pointer can be a different size from a none function
> pointer so it is not safe to store in any other type of pointer, yet
> Posix defines that it is valid. A generic function pointer such as
> void(*)(void) or a lua_Cfunction is perfectly fine.
>
>>> in addition I would also call into question the functions marked
>>> const in (Input::get*) which change the state of union fields.
>>
>> I don't understand this last remark. In lua::Input, there are only
>> Put* members, and
>> none modify the union field (or which one?). In lua::Output, there are
>> "Get*() const"
>> members, which all modify the values pointed to by the PointerValue member,
>> but the object itself is not modified.
>>
>>
>
> Sorry maybe I got the class name mixed up but I do recall there were
> constant functions changing the union.
>
> Liam
>

I just looked again it was the Output class changing the pointer value
and I also see it is storing a function pointer in a void pointer.
Liam