473,385 Members | 1,813 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,385 software developers and data experts.

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 1682
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mahesh Tomar | last post by:
Dear Readers, I am porting my existing C code to C++. In my existing code there are numerous functions that has been defined with CONST qualifier. For eg. foo(const DATA_TYPE *x); DATA_TYPE is...
2
by: fb | last post by:
Hi everyone. I have the following code. It was a question out of C++ how to program. I get a warning about "possible unreachable code" in the RunCode() function, but I don't see any problem with...
1
by: Natalia DeBow | last post by:
Hi, I am working on a Windows-based client-server application. I am involved in the development of the remote client modules. I am using asynchronous delegates to obtain information from...
1
by: Eric | last post by:
Consider the following: class ParentClass { public: void FunctionOne( void ); protected: void FunctionTwo( void ); private: void FunctionThree( void );
14
by: streamkid | last post by:
i'm a learning newbie at c++... and i have the following question... reading some source code, i saw this: int function(const void * one, const void * two) { int var1, var2; var1 =...
29
by: Amar Kumar Dubedy | last post by:
implement a c++ class such that it allows us to add data members at runtime.
12
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
4
by: sip.address | last post by:
Hi there, When creating interfaces and implementations, the usual thing is doing somethign like class Interface { public: virtual void f() = 0; virtual void g() = 0; };
18
by: mdh | last post by:
May I ask the following. By K&R's own admission, the example used to describe function pointers is complex ( on P119). In addition, the use of casts has been stated by some on this group as...
28
by: junky_fellow | last post by:
Guys, Consider a function func(void **var) { /* In function I need to typecast the variable var as (int **) I mean to say, I need to access var as (int **) }
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.