[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
size_t vs. unsigned long
From: |
Karl Berry |
Subject: |
size_t vs. unsigned long |
Date: |
Tue, 6 May 2014 21:40:02 GMT |
> + long len;
> Is using long instead of size_t going to cause dumb declaration
> conflicts?
Again, it's a taste issue.
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.
which meant that subtractions involving it always came out as
positive, which leads me to worry about when I see it.
It seems correct to me that size_t is unsigned. A size (or address for
that matter) is an unsigned number after all.
Anyway, I doubt either of us want to spend time debating the theory of
size_t and similar. To me, the most important factor is that the
existing Info code uses size_t, so new code should too. Just like any
other coding convention.
thanks,
karl
P.S. Don't get me wrong, I am no fan of size_t. They've caused me a lot
of trouble with useless declaration conflicts. But I've seen most of
the code I originally wrote using [unsigned] long, before size_t
existed, have to be converted to using size_t for one reason or another.
So I think it's a losing battle.