Is this even possible when the read value is 16 bit wide? Wouldn't EOF represent a number?
Ya, I think you're right (and there are some other similar functions that look wrong too).
int32_t al_fread32le(ALLEGRO_FILE *f, bool *ret_success)
doing it right.
But i would prefer
bool al_fread32le(ALLEGRO_FILE *f, int32_t *value);
This way you can do
if (al_fread32le(stream, &number)) { ... }
I suggested this same thing a while ago. I believe the current solution is (or was) to check via an error function.
I don't particularly like the "ret_success" solution either, although perhaps it's better for the rare times that you don't actually want to use a variable to store the data.
Can we have both?
I suppose "bool al_fread16le(ALLEGRO_FILE *f, int16_t w);" has a certain symmetry with "size_t al_fwrite16le(ALLEGRO_FILE *f, int16_t w);".
If its going to return a status, maybe it should probably also be size_t, and report how much it read back. Of course it provides no way to rescue from a short read, so the information would be mostly useless, but it would match the fwriteNNmm functions and the base fread and fwrite functions.
Just an idea.