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

_Generic is a language keyword, not a user-defined macro. It uses an underscore-prefixed name (along with many other C11 keywords/features) precisely because those names are reserved and won't conflict with user code.

Also, that SO post is about C++, not C. It might seem pedantic (particularly given that C actually does have the same rule for reserved names), but that's something to be careful about as there's significant divergence nowadays.



Sorry; I didn't realise that _Generic is a C11 keyword:

http://en.wikipedia.org/wiki/C11_(C_standard_revision)

  Also, that SO post is about C++, not C.
No, it's about both C++ and C:

  Because C++ is based on the C standard (1.1/2, C++03) and
  C99 is a normative reference (1.2/1, C++03) these also
  apply, from the 1999 C Standard...
See section 7.1.3 of the relevant standard:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf

Also, the divergence has actually been lessened since the C++11 committee worked closely with the C11 committee to bring the standards closer together.

That's part of why Microsoft is picking up a lot of C99 as part of their work for implementing C++11.


Good catch on the C/C++ standard relation, I somehow completely missed that when I read the SO answer. Glad to hear that that situation is improving.




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

Search: