![]() |
|
int16_t al_fread16le(ALLEGRO_FILE *f) returns EOF? |
Martin Kalbfuß
Member #9,131
October 2007
![]() |
Is this even possible when the read value is 16 bit wide? Wouldn't EOF represent a number? http://remote-lisp.spdns.de -- my server side lisp interpreter |
Trent Gamblin
Member #261
April 2000
![]() |
Ya, I think you're right (and there are some other similar functions that look wrong too).
|
Martin Kalbfuß
Member #9,131
October 2007
![]() |
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)) { ... }
http://remote-lisp.spdns.de -- my server side lisp interpreter |
Matthew Leverton
Supreme Loser
January 1999
![]() |
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. |
ImLeftFooted
Member #3,935
October 2003
![]() |
Can we have both? |
Peter Wang
Member #23
April 2000
|
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);".
|
Thomas Fjellstrom
Member #476
June 2000
![]() |
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. -- |
|