Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I thought that type punning via union is against the standard.

I personally do not think it should be ... It's a very handy tool.



I think it may be a GNU extension to explicitly allow it, but I'm no language lawyer. This header is from glibc; it may explain why it's not available on some platforms.


It’s legal in C.


I think you're right. Most of the top google results seem to be from people who can't mentally separate c and c++. So when i tried to look it up around the time of the comment, i didn't get clear answers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: