What does void pointer actually mean?

N

Niu Xiao

I saw a lot of codes like:

void foo(void* arg)
void bar(void** arg)
f((void*)p)

but what does void pointer mean in c? I just know it stands for generic
pointer.

thanks.
 
K

Keith Thompson

Niu Xiao said:
I saw a lot of codes like:

void foo(void* arg)
void bar(void** arg)
f((void*)p)

but what does void pointer mean in c? I just know it stands for
generic pointer.

Right, it's a generic pointer. I'm not sure what you're asking.

"void" is a special type, an incomplete type that cannot be completed.
You can't have an object of type void; a function that returns void
doesn't return a value.

Type "void*" is a pointer type that can point to any object. An
object of type void* can hold a value of any pointer-to-object type.
Any object type can be implicitly converted to void*, and vice versa.
 
J

Jack Klein

Right, it's a generic pointer. I'm not sure what you're asking.

"void" is a special type, an incomplete type that cannot be completed.
You can't have an object of type void; a function that returns void
doesn't return a value.

Type "void*" is a pointer type that can point to any object. An
object of type void* can hold a value of any pointer-to-object type.
Any object type can be implicitly converted to void*, and vice versa.

Of course you meant your last sentence above to read:

A pointer to any object type can be implicitly converted to void*, and
vice versa.
 
K

Keith Thompson

Jack Klein said:
in comp.lang.c: [...]
Type "void*" is a pointer type that can point to any object. An
object of type void* can hold a value of any pointer-to-object type.
Any object type can be implicitly converted to void*, and vice versa.

Of course you meant your last sentence above to read:

A pointer to any object type can be implicitly converted to void*, and
vice versa.

Yes, thanks.
 
N

Niu Xiao

Keith said:
Right, it's a generic pointer. I'm not sure what you're asking.

"void" is a special type, an incomplete type that cannot be completed.
You can't have an object of type void; a function that returns void
doesn't return a value.

Type "void*" is a pointer type that can point to any object. An
object of type void* can hold a value of any pointer-to-object type.
Any object type can be implicitly converted to void*, and vice versa.
> Any object type can be implicitly converted to void*, and vice versa.
This sentence tells everything, thanks.
 
K

Keith Thompson

Niu Xiao said:
Keith Thompson wrote: [...]
Any object type can be implicitly converted to void*, and vice versa.
This sentence tells everything, thanks.

Except that it's wrong.

Any pointer-to-object type (not any object type) can be implicitly
converted to void*, and vice versa.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top