Subject: Re: ansi.h merger
To: Christos Zoulas <>
From: Todd Vierling <>
List: tech-toolchain
Date: 07/28/2001 12:26:41
[Moved back to tech-toolchain]

On Sat, 28 Jul 2001, Christos Zoulas wrote:

: | Huh?  Unless you have a specific counterexample, all cases where the
: | compiler is warning about type conversion portability problems are perfectly
: | correct in their assertions.
: It is a PITA to change int's in structures to size_t's, or cast every use
: of them.

If the struct member really is "int", you have to cast it anyway -- you lose
signedness if you try to autoconvert it to size_t (which is unsigned).  This
is required.

If the struct member is "unsigned [int]", you shouldn't have to cast it, as
the autoconversion rules in C99 will let this be promoted to "unsigned long"
(where that is the type of size_t) without a warning.

Welcome to code portability.  (You did write that in the new bylaws as a
goal, right?  This is tongue-in-cheek, mind you, not meant as a jab.  8-)

: | : It is a problem when you have an int that you are passing in a size_t
: | : parameter argument. consider:
: | :
: | :     strncpy(foo, bar, 13);
: | :
: | : Well, is that 13U or 13UL? Or should I need to cast it to (size_t)13?
: |
: | C99 type conversion rules allow this case to be promoted without a warning,
: | because the default case of nonnegative "int" constant can be promoted to
: | "unsigned int" and then "unsigned long" automatically.
: I know, but lint bitches.

Then we should fix lint.  It shouldn't bitch on this case, because "13" is a
nonnegative constant.

: | Not all can be made MI, mind you.  I found clock_t as one such type already,
: | but I haven't scanned through everything.
: most of them can though.

Fine, so we can audit them and see which can be moved out, and move those.

IMNSHO, I'd rather see these typedef'd in terms of the bitsized types where
possible, to help readability, but that will again lead you down the path of
incongruous types on some platforms.  Then again, some of those types can
probably be collapsed to MI definitions too.

-- Todd Vierling <>  *  Wasabi NetBSD:  Run with it.
-- NetBSD 1.5 now available on CD-ROM  --