MU_ENUM_VALUE_COUNT is misleading
- Dominant language
- C
- Stars
- 8
- Forks
- 17
- Avg merge
- 31m
- Merged PRs (30d)
- 3
Description
Given the following enum definition:
```c
#define BSDL_METADATA_DATA_RESULT_VALUES \
BSDL_METADATA_DATA_FAILURE, \
BSDL_METADATA_DATA_INVALID, \
BSDL_METADATA_DATA_OK \
MU_DEFINE_ENUM(BSDL_METADATA_DATA_RESULT, BSDL_METADATA_DATA_RESULT_VALUES)
```
One would reasonably write:
```c
int n=MU_ENUM_VALUE_COUNT(BSDL_METADATA_DATA_RESULT);
```
However, "n" will not have the expected value (something out of range of the enum values), instead will get the value `BSDL_METADATA_DATA_INVALID`, which is well within the range of the enum values.
I suspect this could be fixed in several ways:
1) document the intended usage of `MU_ENUM_VALUE_COUNT`.
2) "magically" make the construct fail at compile time
Best Regards,
Andrei Porumb
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.