4 ms·
> enumerating struct members in preprocessor macros (something like:) I considered something along these lines: my main use case would be to produce string ver
by AlbertoGP 5y ago
> enumerating struct members in preprocessor macros (something like:)
I considered something along these lines: my main use case would be to produce string versions of enum values, like Rust’s «#[derive(Debug)]».
The problem is that, without type information, it would be too fragile, so I decided to leave it out.
Still, I’ll consider what you propose, maybe there is some form of purely syntactical macro that could cover these use cases.
- eqvinox 5y ago> The problem is that, without type information, it would be too fragile, so I decided to leave it out. typeof() is being considered for ISO C2x and has been around for ages in GCC/clang. _Generic is already in C11. With a struct member iterator, these 2 could/should be useful to branch out into type specific handling for each field. Admittedly those are somewhat limited, particularly when working with typedefs, but that's a bit of a fundamental problem in C :(