I don't think that is possible in standard C (PIC & XC8).
I was trying to use an enum so that any out of range item would generate a compile time error but in another part of the program I want to be able to iterate through through all the values in the enum so I can't do that. I could put the values in a constant array which would be easy to iterate but then using an incorrect value would not generate a compile time error.
Is there some way of achieving both requirements?
I was trying to use an enum so that any out of range item would generate a compile time error but in another part of the program I want to be able to iterate through through all the values in the enum so I can't do that. I could put the values in a constant array which would be easy to iterate but then using an incorrect value would not generate a compile time error.
Is there some way of achieving both requirements?