On Sat, Nov 12, 2011 at 4:43 PM, Hans-Christoph Steiner <[email protected]> wrote:

> In the case of type-punning, I think that code should be replaced with 
> something that uses a different technique rather than making separate type 
> punning for 32 and 64 bits.  I think unions can be used in many of those 
> situations.  Type punning is very deprecated and not allowed in the C99 
> standard (which is 12 years old).

Yes I replace all type punning with unions, in the way PD_BIGORSMALL
is defined in Pd-extended and Pd-double. It is a kind of 'legitimate
type punning', still a way to access a float variable as an int, and
Qt devs reportedly had problems with such a method. See
http://labs.qt.nokia.com/2011/06/10/type-punning-and-strict-aliasing/.
I've also experimented with memcpy(), this is completely safe, and not
expensive because memcpy() translates to a single instruction for a
float or double. But the disadvantage is, it needs <string.h>, and I
did not want to include <string.h> in m_pd.h because it would be
included in every executable then.


Katja

_______________________________________________
Pd-dev mailing list
[email protected]
http://lists.puredata.info/listinfo/pd-dev

Reply via email to