[gccsdk] fgets problem/Unixlib

Lee Noar leenoar at sky.com
Wed Mar 5 12:06:57 PST 2014


On 04/03/14 11:05, david_m_gee wrote:
> On GCC 4.1.2/Unixlib, running on a Raspberry Pi, fgets() does not appear
> to work. It returns NULL when there is data in the file to read. It
> makes no difference whether the code is statically or dynamically
> linked, but the shared C library version works fine with exactly the
> same data file.
>
> See https://www.riscosopen.org/forum/forums/11/topics/2447 for further
> details.

I tried the test binaries, both dynamic and static, with RISC OS running
in rpcemu. They both worked as expected. When you say that there is an
infinite loop, do you get:

0 :

repeated over and over? I found that this occurred when the test file
was not found. For example, from the directory holding the binary and
test file:

testdynamic errors/lst

failed with an infinite loop as above, but

testdynamic errors.lst

worked correctly.
This may explain why it works with the SharedCLibrary as it doesn't
use filename translation.

Perhaps you could alter the code to test the result of fopen to ensure
the file is in fact being found?

Thanks,
Lee.





More information about the gcc mailing list