On Wed, 08 Nov 2017 17:44:50 +0000 Ralph Corderoy <ralph(a)inputplus.co.uk> wrote:
Ralph Corderoy writes:
Hi Bakul,
void* serves a different purpose. It says this is
an untyped pointer
(or a ptr to an instance of any type) so no question of size being an
issue.
In C, ignoring POSIX, a void pointer is big enough to hold any pointer
to data. Pointers to data may be different sizes. And a void pointer
can't hold a function pointer, but all function pointers are defined to
be the same size. Thus `void (*)(void)' can be used as a generic
function pointer type and cast to other ones when needed.
Yes, I was being sloppy, not mentiong the fn ptr exception.
I was saying `void *' represents a generic non-function
pointer. I was just separating it from what Ron wants, which
is, if I understand right, is a pointer to the *smallest*
addressable memory unit. I agree that `char' shouldn't do
double duty as the smallest addressable unit and I was
suggesing uint8_t does that job. But that is not true either.
There are word addressable machines where you can't directly
address bytes (if they have 8 bit bytes). Nor would you want a
"byte pointer" to be a general pointer.
It
shouldn't even have been "void*". I would've preferred _* and _
instead of void* and void. Much more appropriate for a concise
language like C!
That's awful. Might as well say `return' occurs so often, it should
have been `@'. :-)
Fits right in with "e1 ? e2 : e3" :-) My thinking was that the
word void loses any meaning in "void *". It is a not a pointer
to an empty space. Seems people just didn't want to add a new
keyword so they reused void. _ is alreast more mnemonic.