This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Don't discuss details of what type size_t might be typedefed to
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: libc-alpha at sourceware dot org
- Date: Mon, 27 Feb 2012 01:05:51 +0000 (UTC)
- Subject: Don't discuss details of what type size_t might be typedefed to
As a third piece of removing inappropriate references to the GNU
system, I propose this patch removing a statement about the types to
which size_t may be equivalent, and the following discussion about
when two integer types, of the same size and signedness, are different
in a way that matters.
The statement that size_t is one of unsigned int or unsigned long int
*is* true for anything that might be called a GNU system - the GNU
Coding Standards specifically say that portability to systems where
size_t is unsigned long long int, wider than unsigned long int, does
not matter, so I think we can assume such systems will not be GNU
systems. But I don't think that's a relevant detail for the glibc
manual. The statement that the two possible types are equivalent is
only true for 32-bit systems, so making this text accurate as a whole
would involve complicating it with conditionals about 64-bit systems.
And the discussion of how the types being distinct matters for
declaring a system function is about something of little current
relevance - nowadays people just get prototype declarations of system
functions from the system headers. So I think it's best just to
describe size_t abstractly without detailing particular types it might
be equivalent to.
lang.texi has yet another phrase for GNU system or library variants,
"GNU C system". I'm inclined to think, from other similar entries,
that this is a synonym for "GNU C library".
2012-02-27 Joseph Myers <joseph@codesourcery.com>
* manual/lang.texi (size_t): Do not describe particular types to
which size_t is equivalent or when differences between them are
significant.
diff --git a/manual/lang.texi b/manual/lang.texi
index b93ad5b..70471d3 100644
--- a/manual/lang.texi
+++ b/manual/lang.texi
@@ -635,21 +635,6 @@ this type to specify object sizes.
arguments or variables that hold the size of an object.
@end deftp
-In the GNU system @code{size_t} is equivalent to either
-@w{@code{unsigned int}} or @w{@code{unsigned long int}}. These types
-have identical properties on the GNU system and, for most purposes, you
-can use them interchangeably. However, they are distinct as data types,
-which makes a difference in certain contexts.
-
-For example, when you specify the type of a function argument in a
-function prototype, it makes a difference which one you use. If the
-system header files declare @code{malloc} with an argument of type
-@code{size_t} and you declare @code{malloc} with an argument of type
-@code{unsigned int}, you will get a compilation error if @code{size_t}
-happens to be @code{unsigned long int} on your system. To avoid any
-possibility of error, when a function argument or value is supposed to
-have type @code{size_t}, never declare its type in any other way.
-
@strong{Compatibility Note:} Implementations of C before the advent of
@w{ISO C} generally used @code{unsigned int} for representing object sizes
and @code{int} for pointer subtraction results. They did not
--
Joseph S. Myers
joseph@codesourcery.com