cmpsb wrote:
If you insist on using uint8_t, how about
Code:
uint8_t current_entry = 0;
do
{
...
current_entry += 1;
} while (current_entry > 0);
?
Sounds interesting, if not a little hackish, although I'm not familiar with using do ... while loops in C so I am more likely to get "off-by-one" bugs if I use them in the few places where I need to iterate through this table.
bluemoon wrote:
onlyonemac wrote:
So how should I make it so that I can count 256 values in a uint8_t? Using a uint16_t seems a bit wasteful here
No. The array index will likely to be promoted to native address size anyway.
I suggest to use native integer or size_t to give you flexibility to change the table size.
That seems like a good idea; I might do that, although the thing is that if I switch to a 32-bit index then I feel compelled to "max out" the array size and have 4294967296 entries lol. Such are the joys of Asperger's...
Anyway, I might just leave it at 255 for now. This table is really only used in one code module, and the size of the table doesn't honestly affect anything except the maximum number of items that can be handled by that module. 256 is more than enough; extending it at any time would require modification of that module only because of the abstraction between it and other modules.