[PD-dev] Passing creation arguments to newmethod

Claude Heiland-Allen claude at mathr.co.uk
Wed Aug 11 16:49:17 CEST 2021


Hi,

On 06/08/2021 12:26, Claude Heiland-Allen wrote:
> On 05/08/2021 22:32, Christof Ressi wrote:
>> Fun fact: pd_typedmess() often calls function pointers with more 
>> arguments than the original functions - which is undefined behavior. 
>> It just happens to work because in the default calling convention 
>> ("cdecl") the caller cleans up the stack. With other calling 
>> conventions where the *callee* has to clean up the stack, e. g. 
>> "stdcall", this would lead to stack corruption and crash horribly :-)
>
> I had to fix this in my patches to compile for web with Emscripten, 
> where function pointers must be called at their exact type (or the 
> Emscripten runtime stops hard).
>
> https://github.com/pure-data/pure-data/pull/688
>
> May need a little care and attention before merging, sorry I haven't 
> been more proactive on this one.

Should be good to go now; I force-pushed a re-do relative to current master.

I checked in some generated code because it should change very rarely 
(if ever), and the work required to properly run the code generator at 
compile time is out of all proportion to the benefit.


Claude

-- 

https://mathr.co.uk







More information about the Pd-dev mailing list