Casting pointers

Doug Gwyn gwyn at smoke.BRL.MIL
Mon Oct 1 12:12:39 AEST 1990


In article <1990Sep29.201144.23113 at maths.tcd.ie> tim at maths.tcd.ie (Timothy Murphy) writes:
>when temporarily 'borrowing' od from Unix to Mac.

Assuming you're talking about AT&T's proprietary source code,
that is not "borrowing", it's theft.

>char *buf = "abc";
>  int *n = (int*) buf;
>Should this always work?

Of course not.  You may cast pointers to objects with more stringent
alignment requirements to pointers to objects having less stringent
or the same alignment requirements, not the other way around.



More information about the Comp.std.c mailing list