Paul Pluzhnikov wrote:
> "Earl Purple" <[EMAIL PROTECTED]> writes:
>
> The buffer into which you received the data must not have been
> properly aligned.
>
> You have to either do that, or ensure that the data is properly
> aligned in the buffer. For example:
>
>   union { char buf[200]; double d; } u;
>   receive_data(u.buf, sizeof(buf));
>   double *p = reinterpret_cast<double*>(u.buf); // OK
>   p = &u.d; // same thing

Thank you. This was resolved also on comp.lang.moderated.c++. For those
who use boost they have a special template to do what you just did
above with the union.
(boost::aligned_data or something like that).

_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to