Just curious if u_char is a standard. I\'ve always used it assuming it was defined along with uintX_t types and so on. But am seeing some of our code base transition from
It's not present in any older header files (except certain specific areas, like Kerberos and networking headers), and not a built-in type in any compiler I know of.
The string u_char
does not appear in this draft of the C standard:
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf
It's not required by POSIX either, as far as I know.
I think it's in BSD (sys/types.h), and Windows (winsock.h). I would not consider either one to be "a standard" - they aren't formal standards, and they certainly aren't part of standard C, but they are clearly defined and documented.
No, u_char
is non-standard. If you need to use a standard type that's equivalent to u_char
, you can use uint8_t
which is part of the C99 standard library (check your specific platforms/compilers for C99-compliance). stdint.h
defines this type (along with many other specific integral types). This Wikipedia article contains more information about stdint.h.