469,609 Members | 1,933 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Question on VOID

Hello all,

I wonder about void?

To which category in the C programming language does it belong?
Of how many bits consits void?

Is it possible to define a varibale called
void a;

Thank you all for your comments!

Zeh

Oct 16 '07 #1
10 1498
Zero wrote:
>
Hello all,

I wonder about void?

To which category in the C programming language does it belong?
(void) is an "incomplete type".
Of how many bits consits void?

Is it possible to define a varibale called
void a;
No.

--
pete
Oct 16 '07 #2
On Oct 16, 6:54 am, Zero <chefmue...@web.dewrote:
Hello all,

I wonder about void?

To which category in the C programming language does it belong?
Of how many bits consits void?

Is it possible to define a varibale called
void a;

Thank you all for your comments!

Zeh
Zero,

1. "void" is a datatype in C.
2. "void" is typically the same number of bits as your processor's
architecture.
- So in an 8-bit micro void would be 8-bits. You will need to
verify this in your compiler though.
3. You cannot define a variable as "void a;" but you can define a
pointer as "void *a;".
- Void pointers are used to pass typeless data into and out of
functions.
- Void pointers can also be use to pass pointers to other
functions (i.e. function pointers).

Here is a link that explains this further.

http://tigcc.ticalc.org/doc/keywords.html#void

Hope this helps,

Keith
http://www.doubleblackdesign.com

Oct 16 '07 #3
husterk wrote:
....
2. "void" is typically the same number of bits as your processor's
architecture.
- So in an 8-bit micro void would be 8-bits. You will need to
verify this in your compiler though.
"void" is an incomplete type that cannot be completed; it doesn't have a
size.

You may be thinking about the fact that some compilers encourage people
to write defective code by allowing pointer arithmetic on void*
pointers, in which context it is treated essentially the same as char*.
Thus, the effective size in bits is CHAR_BITS. However, if you're going
to refer to that "feature", you should warn that it is
implementation-specific.
Oct 16 '07 #4
husterk wrote:
On Oct 16, 6:54 am, Zero <chefmue...@web.dewrote:
>Hello all,

I wonder about void?

To which category in the C programming language does it belong?
Of how many bits consits void?

Is it possible to define a varibale called
void a;

Thank you all for your comments!

Zeh

Zero,

1. "void" is a datatype in C.
Right.
2. "void" is typically the same number of bits as your processor's
architecture.
- So in an 8-bit micro void would be 8-bits. You will need to
verify this in your compiler though.
Wrong. `void' is an "incomplete type" and has no
size at all, not even zero size.
3. You cannot define a variable as "void a;" but you can define a
pointer as "void *a;".
Right.
- Void pointers are used to pass typeless data into and out of
functions.
That is one of their uses.
- Void pointers can also be use to pass pointers to other
functions (i.e. function pointers).
Wrong. A `void*' is a pointer to data, not a pointer
to functions. Pointers to data and pointers to functions
are not compatible.
Here is a link that explains this further.

http://tigcc.ticalc.org/doc/keywords.html#void
Here is a link that explains this further.

http://www.c-faq.com/

.... with special attention to Question 4.6, 4.9, and 4.13.

--
Eric Sosman
es*****@ieee-dot-org.invalid
Oct 16 '07 #5
Eric Sosman <es*****@ieee-dot-org.invalidwrites:
husterk wrote:
>On Oct 16, 6:54 am, Zero <chefmue...@web.dewrote:
>>Hello all,

I wonder about void?

To which category in the C programming language does it belong?
Of how many bits consits void?

Is it possible to define a varibale called
void a;

Thank you all for your comments!

Zeh

Zero,

1. "void" is a datatype in C.

Right.
>2. "void" is typically the same number of bits as your processor's
architecture.
- So in an 8-bit micro void would be 8-bits. You will need to
verify this in your compiler though.

Wrong. `void' is an "incomplete type" and has no
size at all, not even zero size.
Without firing up the compile this then means it's impossible to malloc
a block of memory to store pointers to data passed to printf?

How can, in English not C, a variable not have a size? It holds data. So
it has a size at least equal to the data it can hold.

Oct 16 '07 #6
Richard wrote:
Eric Sosman <es*****@ieee-dot-org.invalidwrites:
> Wrong. `void' is an "incomplete type" and has no
size at all, not even zero size.

Without firing up the compile this then means it's impossible to malloc
a block of memory to store pointers to data passed to printf?
Are you talking about variables of type "void *"? The size of "void *"
is independent of the size of "void".
How can, in English not C, a variable not have a size? It holds data. So
it has a size at least equal to the data it can hold.
Your logic is impeccable. If indeed a variable existed which had type
"void", it would have a size. But no such variable exists, so this
problem does not arise.

--
Philip Potter pgp <atdoc.ic.ac.uk
Oct 16 '07 #7
Philip Potter <pg*@see.sig.invalidwrites:
Richard wrote:
>Eric Sosman <es*****@ieee-dot-org.invalidwrites:
>> Wrong. `void' is an "incomplete type" and has no
size at all, not even zero size.

Without firing up the compile this then means it's impossible to malloc
a block of memory to store pointers to data passed to printf?

Are you talking about variables of type "void *"? The size of "void *"
is independent of the size of "void".
>How can, in English not C, a variable not have a size? It holds data. So
it has a size at least equal to the data it can hold.

Your logic is impeccable. If indeed a variable existed which had type
"void", it would have a size. But no such variable exists, so this
problem does not arise.
You are quite correct. My mind was drifting. Hopefully the rot has
stopped. I can't think what I was thinking....
Oct 16 '07 #8
Richard wrote On 10/16/07 10:31,:
Eric Sosman <es*****@ieee-dot-org.invalidwrites:

>>husterk wrote:
>>>
2. "void" is typically the same number of bits as your processor's
architecture.
- So in an 8-bit micro void would be 8-bits. You will need to
verify this in your compiler though.

Wrong. `void' is an "incomplete type" and has no
size at all, not even zero size.


Without firing up the compile this then means it's impossible to malloc
a block of memory to store pointers to data passed to printf?

How can, in English not C, a variable not have a size? It holds data. So
it has a size at least equal to the data it can hold.
I think you have confused `void' and `void*'. The
former is an incomplete type, holds no data, and has no
size; there are no variables anywhere of type `void'.
The latter is a complete type, holds data, and has a
size; `void*' variables are as common as mud.

--
Er*********@sun.com

Oct 16 '07 #9
[comp.lang.c] Philip Potter <pg*@see.sig.invalidwrote:
Your logic is impeccable. If indeed a variable existed which had type
"void", it would have a size. But no such variable exists, so this
problem does not arise.
There was a thread a few months ago about about a hypothetical variant
of C with exactly one value of type void, but I can't seem to locate
in Google's archives.

--
C. Benson Manica | I appreciate all corrections, polite or otherwise.
cbmanica(at)gmail.com |
----------------------| I do not currently read any posts posted through
sdf.lonestar.org | Google groups, due to rampant unchecked spam.
Oct 16 '07 #10
Eric Sosman <Er*********@sun.comwrites:
Richard wrote On 10/16/07 10:31,:
>Eric Sosman <es*****@ieee-dot-org.invalidwrites:

>>>husterk wrote:

2. "void" is typically the same number of bits as your processor's
architecture.
- So in an 8-bit micro void would be 8-bits. You will need to
verify this in your compiler though.

Wrong. `void' is an "incomplete type" and has no
size at all, not even zero size.


Without firing up the compile this then means it's impossible to malloc
a block of memory to store pointers to data passed to printf?

How can, in English not C, a variable not have a size? It holds data. So
it has a size at least equal to the data it can hold.

I think you have confused `void' and `void*'. The
former is an incomplete type, holds no data, and has no
size; there are no variables anywhere of type `void'.
The latter is a complete type, holds data, and has a
size; `void*' variables are as common as mud.
I certainly did. See other reply. My mind was wandering.
Oct 16 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mahesh Tomar | last post: by
2 posts views Thread by fb | last post: by
1 post views Thread by Natalia DeBow | last post: by
1 post views Thread by Eric | last post: by
14 posts views Thread by streamkid | last post: by
29 posts views Thread by Amar Kumar Dubedy | last post: by
12 posts views Thread by Bryan Parkoff | last post: by
4 posts views Thread by sip.address | last post: by
18 posts views Thread by mdh | last post: by
28 posts views Thread by junky_fellow | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.