"void **" : Is it valid and what does it mean?
Richard A. O'Keefe
ok at goanna.cs.rmit.oz.au
Tue May 28 17:17:22 AEST 1991
Yes, void ** is valid, and it means pointer-to-generic pointer.
Note that void ** itself may be represented some other way entirely;
void ** is not itself a generic pointer.
In article <AJ3U.91May27213633 at jade.cs.virginia.edu>, aj3u at jade.cs.virginia.edu (Asim Jalis) writes:
> func(void **p)
> { ... }
>
> main()
> { int *i; float *f; char *c;
>
> func(&i); func(&f); func(&c);
> }
>
> However, the compiler gives me warnings about incompatible type for
> all the function calls.
The compiler is RIGHT. You promised it (oh, you deceiver) that
you would give func() pointers to generic (void*) pointers
(call the representation of generic pointers REPRESENTATION 0)
But you lied (oh, you scoundrel, you). You gave it
-- a pointer to (a pointer to int -- REPRESENTATION 1)
-- a pointer to (a pointer to float -- REPRESENTATION 2)
-- a pointer to (a pointer to char -- REPRESENTATION 0)
char* and void* use the same representation.
But void*, int*, and float* need not even be the same _size_, let
alone use the same physical representation.
> The code itself works fine,
no, there is a bug in there, waiting, like a blood-sucking insect
poised on a bush waiting for a deer to pass by, for an opportunity to bite.
> Basically what I want is a type that would coerce to a pointer to a
> pointer to a type, for any type. Sort of one level beyond simple
> "void *".
Why do you want to do _that_? If you _could_ do it, you would be
throwing away information that the receiver would need in order to
be able to _use_ the thing? What's the context?
--
Should you ever intend to dull the wits of a young man and to
incapacitate his brains for any kind of thought whatever, then
you cannot do better than give him Hegel to read. -- Schopenhauer.
More information about the Comp.lang.c
mailing list