Hacker News new | past | comments | ask | show | jobs | submit login

datatype99 generates a switch expression under the hood, and modern compilers check this switch expression for exhaustiveness.



How do compilers check for exhaustiveness when the domain is unbound? Or rather: how does one constrain an integer in C? C enums are glorified consts, it’s still legal to do `myenum_t x = 0xFFFF` where 0xFFFF is not a defined value. This is necessary to allow for flags/bitfield enums.




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

Search: