<div dir="ltr"><div></div><div>If I understood correctly you get a segfault when having the C function with 2 args (s7_scheme and s7_pointer)</div><div>but passing only s7_scheme.</div><div><br></div><div>This seems relevant: <a href="https://stackoverflow.com/questions/12572575/i-can-call-a-function-imported-with-dlsym-with-a-wrong-signature-why">https://stackoverflow.com/questions/12572575/i-can-call-a-function-imported-with-dlsym-with-a-wrong-signature-why</a></div><div>and particularly the answer saying</div><div>&quot;C uses cdecl call conversion (so caller clears the stack) [..]</div><div>But actually behavior is undefined&quot;</div><div><br></div><div>In any case, I&#39;m really noob in this area so that&#39;s all I can contribute.</div><br><div>So my 2 cents:</div><div>- when not having passed init_args: calling the C init_func(s7_scheme)</div><div>  (serving also as backwards compatibility)</div><div>- when init_args is present, calling init_func(s7_scheme, s7_pointer)<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 22 Oct 2020 at 21:57, &lt;<a href="mailto:bil@ccrma.stanford.edu">bil@ccrma.stanford.edu</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; how does C behave if you assume that the called function has a <br>
&gt; signature<br>
&gt; of (s7_scheme* sc) and you try to pass (s7_scheme* sc, s7_pointer args) <br>
&gt; ?<br>
<br>
I tried it with the tlib example, and if you declare args in C, but<br>
don&#39;t pass them in scheme (i.e. no init_args in the environment),<br>
I get a segfault.  The other way (no args declared, but you pass and<br>
use them anyway) seems to work -- strange!  This is in gcc 10.2<br>
in Linux.<br>
<br>
</blockquote></div>