Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > What does void pointer actually mean?

Reply
Thread Tools

What does void pointer actually mean?

 
 
Niu Xiao
Guest
Posts: n/a
 
      05-03-2006
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.
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      05-03-2006
Niu Xiao <> writes:
> 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.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      05-03-2006
On Wed, 03 May 2006 04:58:09 GMT, Keith Thompson <kst-> wrote
in comp.lang.c:

> Niu Xiao <> writes:
> > 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.


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.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      05-03-2006
Jack Klein <> writes:
> On Wed, 03 May 2006 04:58:09 GMT, Keith Thompson <kst-> wrote
> 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.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Niu Xiao
Guest
Posts: n/a
 
      05-05-2006
Keith Thompson wrote:
> Niu Xiao <> writes:
>
>>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.
>


> Any object type can be implicitly converted to void*, and vice versa.

This sentence tells everything, thanks.
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      05-05-2006
Niu Xiao <> writes:
> 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.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the difference between void proba(); and void proba(void); ??? PencoOdStip@gmail.com C++ 1 05-23-2007 07:12 PM
Conversion from 'void*' to pointer to non-'void' requires an explicit cast Hakirato C++ 4 10-05-2006 04:02 PM
what is the difference, void func(void) and void fucn() noblesantosh@yahoo.com C Programming 5 07-22-2005 04:38 PM
"void Method()" vs "void Method(void)" Ollej Reemt C++ 7 04-22-2005 03:47 AM
`void **' revisited: void *pop(void **root) Stig Brautaset C Programming 15 10-28-2003 09:03 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57