<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 27, 2014 at 6:19 PM, Martin Peach <span dir="ltr"><<a href="mailto:martin.peach@sympatico.ca" target="_blank">martin.peach@sympatico.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On 2014-05-27 04:00, Alexandros Drymonitis wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
    The parameters are passed on the stack, so if it's a little-endian<br>
    machine the first two bytes will be the same for a short as for an int.<br>
    (Big-endians would think argc was zero). The problem arises when the<br>
    called routine looks for the first argv which it expects to find<br>
    right after the short argc on the stack. The caller put a four-byte<br>
    int there so the next two bytes will be zero and all the pointers to<br>
    the argvs will be wrong.<br>
<br>
Since my laptop's processor is an Intel Core 2, it's a little edian one,<br>
right? How can I make my code versatile so that it can compile on either<br>
little or big endian machines? I'm reading Pd's source code ([phasor~]'s<br>
code, for example) but it's beyond my understanding. I kind of<br>
understand the beginning of d_osc.c where the code will try to determine<br>
the endianess of the machine, but when it comes to sorting arguments out<br>
depending on the endianess, I'm at loss.<br>
</blockquote>
<br></div>
You don't need to know the endianness of the machine. The compiler and linker take care of that. (You could use the htons() function on a test short like 1234 to see if the result is the same as the input. If they are the same then you have a big-endian machine.)<br>

As long as you declare your 'new' routine with argc as an int it will just work.<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Another important question I still have is, how do I determine whether<br>
there is a signal coming in the object's inlets, so I know whether to<br>
use the values passed via arguments, or the vectors passed from the dsp<br>
method. I'm asking the same thing over and over again...I'll stop for now.<br>
</blockquote>
<br></div>
I think if you get all zeros on the vector for the inlet you can assume it's not connected. So use the argument values until you get non-zero on the inlet vectors.<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote>
<div>I thought about that, but I do need to send zeros to the vectors some times (for example, raising a signal to a power, raising to the zeroth power will yield a DC of 1, which might be useful sometimes). Of course I can send signals with offsets and subtract the offset in the code, but I don't think this is good design. I'd rather not be able to use arguments.<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
<br>
Martin<br>
<br>
</font></span></blockquote></div><br></div></div>