Re: [PATCH v2 1/2] system_data_types.7: Add 'void *'

From: Alejandro Colomar
Date: Fri Oct 02 2020 - 04:24:44 EST


Hi Paul,

On 2020-10-01 19:32, Paul Eggert wrote:
> If you're going to document this at all, I suggest documenting 'void' as
> well as 'void *', and putting both sets of documentation into the same
> man page.
>

All the types we're documenting are in the same page:
system_data_types(7).
And then we have links with the name of each type.

And yes, I also pretend to document 'void'.


> For 'void *' you should also mention that one cannot use arithmetic on
> void * pointers, so they're special in that way too.

Good suggestion!

> Also, you should
> warn that because one can convert from any pointer type to void * and
> then to any other pointer type, it's a deliberate hole in C's
> type-checking.

Also good. I'll talk about generic function parameters for this.

> It might not also hurt to mention 'void const *', 'void
> volatile *', 'void const volatile *', etc.

Those are qualifiers for the type,
and I don't see how any of them would apply differently to 'void *'
than to any other pointer type (or any type at all),
so I think they don't belong to system_data_types(7).

However, it might be good that someone starts a page called
'type_qualifiers(7)' or something like that.

I would love that someone documents 'volatile' correctly,
as there aren't many good sources about it.
If someone who knows when to use --and especially when not to use--
'volatile', is reading this, think about it :-)
I still wonder if I used it correctly in the few cases I've had to.

BTW, I'll CC the LKML.

>
> For 'void' you can mention the usual things, such as functions returning
> void, and functions declared with (void) parameters, why one would want
> to cast to (void), and so forth.

Yes, I was thinking about that.

>
> You're starting to document the C language here, and if you're going to
> do that you might as well do it right.

I'm trying to do so :)

Thanks,

Alex