I thought most people used the explicit version:
for (size_t i = count; i > 0; --i) {
// use array[i - 1]
}
You can also do something like: size_t index = i - 1;
to not have to use i-1. I believe the compiler optimizes that out anyway to be identical.Yes, this is the best answer. This also works with `-fsanitize=unsigned-integer-overflow`.
I agree that more explicit is almost always better in C. It’s difficult enough as is :D
I would do it exactly like you suggest, but using an explicitly sized type like uint32_t instead.
If I write firmware or low-level code, I almost exclusively use integers with explicit bitwidth.