473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What does void pointer actually mean?

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.
May 3 '06 #1
5 4389
Niu Xiao <gn******@gmail.com> 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) ks***@mib.org <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.
May 3 '06 #2
On Wed, 03 May 2006 04:58:09 GMT, Keith Thompson <ks***@mib.org> wrote
in comp.lang.c:
Niu Xiao <gn******@gmail.com> 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
May 3 '06 #3
Jack Klein <ja*******@spamcop.net> writes:
On Wed, 03 May 2006 04:58:09 GMT, Keith Thompson <ks***@mib.org> 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) ks***@mib.org <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.
May 3 '06 #4
Keith Thompson wrote:
Niu Xiao <gn******@gmail.com> 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.
May 5 '06 #5
Niu Xiao <gn******@gmail.com> 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) ks***@mib.org <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.
May 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Alfonso Morra | last post by:
I have written the following code, to test the concept of storing objects in a vector. I encounter two run time errors: 1). myClass gets destructed when pushed onto the vector 2). Prog throws a...
140
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
21
by: tyler_durden | last post by:
hi there peeps... like I say in the topic, I need to do an e-mail program in C language, and has to be made until the 3th of january..the problem is I'm having some problems with it. I was...
13
by: ranjeet.gupta | last post by:
Dear All What does exactly below code means struct File { void* data; }; typedef struct File File; typedef File* fl;
18
by: __PPS__ | last post by:
Hello, I'm a university student and I'm preparing for my final today. I'm reading course notes, I found completely strange piece of code. It makes me laugh, I think the teacher needs to prepare...
16
by: Abhishek | last post by:
why do I see that in most C programs, pointers in functions are accepted as: int func(int i,(void *)p) where p is a pointer or an address which is passed from the place where it is called. what...
21
by: Niu Xiao | last post by:
I see a lot of use in function declarations, such as size_t fread(void* restrict ptr, size_t size, size_t nobj, FILE* restrict fp); but what does the keyword 'restrict' mean? there is no...
5
by: chandanlinster | last post by:
consider the program, /*********************************************************/ int main() { int a; printf("a = %u\n", a); printf("*a = %u\n", *a); return 0; }
4
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.