[gccsdk] Different behaviour between scl and unixlib
Jan-Jaap van der Geer
jjvdgeer at inbox.com
Sat Sep 25 07:08:49 PDT 2010
I was playing with an old program that I'd always compiled against
the SharedCLibrary with Norcroft, but now I tried unixlib and gcc.
The end result was that my program did not work as expected. I
wonder why. This program shows the problem:
FILE* file = fopen("ram:$.input", "r");
buffer = '\n';
while ((read = fscanf(file, "%10[^\n]%c", buffer, &lastchar)) != EOF)
printf("read: %i: '%s', lastchar = %i\n", read, buffer, lastchar);
If compiled with -mlibscl it reads all lines in ram:$.input, ten
chars at a time, until it encounters a LF. Empty lines are not
really a problem.
Compiled with unixlib, if it encounters an empty line, it does not
read anything at all and ends up in a never ending loop.
Is this correct?
More information about the gcc