[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: size_t vs. unsigned long
From: |
Gavin Smith |
Subject: |
Re: size_t vs. unsigned long |
Date: |
Tue, 6 May 2014 23:33:38 +0100 |
On Tue, May 6, 2014 at 10:40 PM, Karl Berry <address@hidden> wrote:
> Well, as you probably know, there is no guarantee that C size_t is the
> same as unsigned long, so in principle it's not just a matter of taste.
> Though admittedly in practice it is, as far as I know (except on
> Windows, I guess), and for compatibility reasons, I hope that never
> changes. But who knows.
The GNU coding standards say we can assume a long is as big as a
size_t, so I think it is okay to assign the return value of a function
like strlen to a long variable.
"Similarly, don’t make any effort to cater to the possibility that
long will be smaller than predefined types like size_t. "
http://www.gnu.org/prep/standards/standards.html#CPU-Portability