Closed andreaagostini closed 4 years ago
Hi @andreaagostini -- this macro is already defined as you suggest, if I have understood correctly, here:
https://github.com/Cycling74/max-sdk/blob/master/source/c74support/max-includes/ext_obex.h#L508
So perhaps I'm misunderstanding or you are using an older revision of the SDK?
Hi @tap,
actually there is a difference between my proposal and the current definition Compare these: `
vs.
#define object_method_direct(rt, sig, x, s, ...) ((rt()sig)object_method_direct_getmethod((t_object )x, s))((t_object)object_method_direct_getobject((t_object )x, s), __VA_ARGS__) // my proposal`
That is, I suggest that the return value of object_method_direct_getobject() is explicitly cast to t_object*, which is not the case currently. This would avoid a compiler error when compiling as C++.
Okay, I see it now and understand. Does it solve the problem to your liking if we change the line @ https://github.com/Cycling74/max-sdk/blob/master/source/c74support/max-includes/ext_obex.h#L511 to the following?
t_object *object_method_direct_getobject(t_object *x, t_symbol *sym);
Yes, that should do it! Thanks, andrea
Hi,
the provided example of the object_method_direct macro doesn't compile if built as c++, since casting implicitly the void return value of object_method_getobject() to object, for use as the first parameter of the returned method, is illegal.
I suggest to either change the example to
t_jrgba result = object_method_direct(t_jrgba, (void *, double, double), pwindow, gensym("getcolorat"), x, y);
or, probably better, to change the macro to
#define object_method_direct(rt, sig, x, s, ...) ((rt(*)sig)object_method_direct_getmethod((t_object *)x, s))((t_object*)object_method_direct_getobject((t_object *)x, s), __VA_ARGS__)
or even, if possible, to change the return value of object_method_direct_getobject() to t_object* .
Thanks for considering, andrea