c - Can an implementation that has sizeof (int) == 1 "fully conform"? -


this question has answer here:

according the c standard, characters returned fgetc returned in form of unsigned char values, "converted int" (that quote comes c standard, stating there indeed conversion).

when sizeof (int) == 1, many unsigned char values outside of range. possible of unsigned char values might end being converted int value (the result of conversion being "implementation-defined or implementation-defined signal raised") of eof, returned despite file not being in erroneous or end-of-file state.

i surprised find such implementation exists. tms320c55x ccs manual documents uchar_max having corresponding value of 65535, int_max having 32767, fputs , fopen supporting binary mode... what's more surprising seems describe environment conforming, complete implementation (minus signals).

the c55x c/c++ compiler conforms iso c standard defined iso specification ...

the compiler tools come complete runtime library. library functions conform iso c library standard. ...

is such implementation can return value indicating errors there none, really conforming? justify using feof , ferror in condition section of loop (as hideous seems)? example, while ((c = fgetc(stdin)) != eof || !(feof(stdin) || ferror(stdin))) { ... }

the function fgetc() returns int value in range of unsigned char when proper character read, otherwise returns eof negative value of type int.

my original answer (i changed it) assumed there integer conversion int, not case, since function fgetc() returning value of type int.

i think that, conforming, implementation have make fgetc() return nonnegative values in range of int, unless eof returned.

in way, range of values 32768 65535 never associated character codes in tms320c55x implementation.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -