Re: [PATCH 1/2] system_data_types.7: Document size_t

Alejandro Colomar
2020-09-28T14:51:42Z

Hi Dave!

On 2020-09-28 16:15, Dave Martin wrote:
> On Mon, Sep 28, 2020 at 11:55:08PM +1000, G. Branden Robinson wrote:
>> Hi, Alex!
>>
>> At 2020-09-28T15:48:14+0200, Alejandro Colomar wrote:
>>>> Where does this arbitrary-looking list of headers come from?
>>>
>>> There are two parts: left to the ';', and right to the ';'.
>>>
>>> Left: The canonical C standard header, and the canonical POSIX header,
>>> in alphabetical order.
>>>
>>> Right: All other headers that shall define the header, according to
>>> either the C or the POSIX standards, in alphabetical order.
>
> To clarify, does POSIX _guarantee_ that all of those headers define this
> type? (I admit I'm too lazy to search through the POSIX standard for an
> answer to this).

Yes, POSIX does guarantee that all those headers define the type.

>
> If not, this list would serve only to legitimise bad habits and it may
> be better to leave it out.
>
>
>> That's not a bad scheme but it is not inferable from the current man
>> page text; I almost commented on the inconsistency in one of my earlier
>> messages but deemed it out of scope. Please document it, perhaps in an
>> introductory paragraph at the top of the Description section.
>
> Ack, I think it would be better to state this explicity rather than
> having some terse syntax that people need to understand.

Would you like to propose something?

>
>
> IIUC, a program intended to be fully portable between C implementations
> must include <stddef.h>, not rely on one of the others.

Yes, in principle, programmers should use the first header in the list.
However, we listed all of them for completeness. We only listed headers
that guarantee to define the type, thogh, either by C or POSIX:

.\" Layout:
.\" A list of type names (the struct/union keyword will be omitted).
.\" Each entry will have the following parts:
.\" * Include
.\" The headers will be in the following order:
.\" 1) The main header that shall define the type
.\" according to the C Standard,
.\" and
.\" the main header that shall define the type
.\" according to POSIX,
.\" in alphabetical order.
.\" ;
.\" 2) All other headers that shall define the type
.\" as described in the previous header(s)
.\" according to the C Standard or POSIX,
.\" in alphabetical order.
.\" *) All headers that define the type
.\" *if* the type is not defined by C nor POSIX,
.\" in alphabetical order.
.\"
.\" * Definition (no "Definition" header)
.\" Only struct/union types will have definition;
.\" typedefs will remain opaque.
.\"
.\" * Description (no "Description" header)
.\" A few lines describing the type.
.\"
.\" * Conforming to
.\" Format: CXY and later; POSIX.1-XXXX and later.
.\" Forget about pre-C99 C standards (i.e., C89/C90)
.\"
.\" * Notes (optional)
.\"
.\" * See also

>
> (In practice it seems reasonable to include any header that is specified
> to declare types or function prototypes that themselves require a
> definition of size_t, but this is awkward to describe, and not explicit
> in the standard.)
>
> [...]
>
> Cheers
> ---Dave
>

Cheers,

Alex