Subject: Re: [OT] u_int*_t vs. uint*_t - which to use?
To: NetBSD Users <>
From: David Laight <>
List: netbsd-users
Date: 01/19/2002 20:15:25
> I apologize in advance if this is OT, but I've been scouring the 'Net for
> some time and still can't find the answer.  I have been using "intX_t" and
> "u_intX_t" for years in my applications because I believed it was the
> portable thing to do according to POSIX 1003.1.  I have had no problems
> between NetBSD, Linux and HP-UX.   Recently, I discovered that these types
> are not defined anywhere on SunOS 5.6.  Instead, there is "intX_t" (yes,
> the same) and "uintX_t".  These are defined via <inttypes.h>.  Now I see
> that NetBSD, Linux and HP-UX define these as well.  Am I incorrect to use
> the (apparently) old-style "u_intX_t"?  It seems these newer types (via
> <inttypes.h>) are UNIX-98.  I would like to know if this supercedes the
> POSIX types.

We had some discussions about this at the last X/Open Xnet meeting I
was at.  We were trying to guess what the C standard would say,
unfortunately that standards group was failing to make a decision.
I don't know what has happened in the intervening few years, but the
following comment from my Solaris 8 system it probably correct.
(Sun were tracking the C standard, and their XNET rep. had been briefed)

 * This file, <sys/int_types.h>, is part of the Sun Microsystems implementation
 * of <inttypes.h> as proposed in the ISO/JTC1/SC22/WG14 C committee's working
 * draft for the revision of the current ISO C standard, ISO/IEC 9899:1990
 * Programming language - C.
 * Programs/Modules should not directly include this file.  Access to the
 * types defined in this file should be through the inclusion of one of the
 * following files:
 *      <sys/types.h>           Provides only the "_t" types defined in this
 *                              file which is a subset of the contents of
 *                              <inttypes.h>.  (This can be appropriate for
 *                              all programs/modules except those claiming
 *                              ANSI-C conformance.)
 *      <sys/inttypes.h>        Provides the Kernel and Driver appropriate
 *                              components of <inttypes.h>.
 *      <inttypes.h>            For use by applications.
 * See these files for more details.
 * Use at your own risk.  As of February 1996, the committee is squarely
 * behind the fixed sized types; the "least" and "fast" types are still being
 * discussed.  The probability that the "fast" types may be removed before
 * the standard is finalized is high enough that they are not currently
 * implemented.  The unimplemented "fast" types are of the form
 * [u]int_fast[0-9]*_t and [u]intfast_t.

The file then goes on to define:
    [u]int[n]*_t, [u]intmax_t, [u]intptr_t and [u]int_least[n]_t

No hint of a u_xxx type anywhere.

Hope that muddies things...