ucx
ucx copied to clipboard
[WIP] UCP/API: Enforce strongly typed enums
What
Enforce types on enums, to the extent possible by the C standard and the compilers we use.
Why ?
Prevent human errors caused by incorrect usage of enum values, therefore make our code more robust and idiot-proof.
How ?
- Anonymous / named enums are now types (using
typedef
). - Use typed enums wherever possible (vars, func params). Can’t use them in struct members, would be bad practice.
- Add compiler flags to enforce correct usage.
- Fix docs accordingly.
The PR is not to be merged. Its purpose is to be a “demo” on a small part of the code of how the real change will look like – so that we can see whether it is appropriate, before proceeding to do more.
@yosefe @brminich WDYT? - See PR description. It looks far from perfect, but as C doesn’t really have strong enum types, I think that’s the best we can do, and it’s better than what we have now
This makes code better. I would start with internal changes first before changing externally exposed structures. I don't think it will break API/ABI but I think it may potentially generate warning in codes using UCX.