Re: void vs void* (philosophical question)
- From: Chris Torek <nospam@xxxxxxxxx>
- Date: 30 Jun 2006 18:04:47 GMT
In article <e82s8v$ho9$1@xxxxxxxxxxxxxxxxx>
Giannis Papadopoulos <ipapadop@xxxxxxxxxx> wrote:
According to the standard (ISO C99 draft WG14/N1124), void is the
incomplete type that cannot be completed and comprises the empty set of
values. Since it declares the absense of a value can it be considered a
data type?
In a larger, "not Standard C" sense, yes. In Standard C, however,
types are partitioned into "object types", "function types", and
"incomplete types". (The Standard does not define "data type" but
logically it would appear to map to "object type". Interestingly,
my C99 draft *uses* the phrase "data types" in the description of
<wchar.h>, in paragraph 1 of section 7.19.1. It is clear enough
that it does not mean "incomplete types" here. Perhaps the phrasing
was changed in the final standard, though.)
(If I were in charge of things, I would probably make "void" an
ordinary object type whose size is zero, so that sizeof(void) ==
0; its value, upon conversion to any other scalar type, would be
zero. Thus:
void v, *pv = &v;
printf("%d %d\n", v, *pv);
would print "0 0\n". :-) Of course, I would also add zero-sized
arrays:
int a[0], b;
with the allowance -- but not requirement -- that &a[0] == &b. Then
I might also remove the "flexible array member" and simply bless the
Struct Hack.)
Regarding void*, is it just a simple reuse of the same keyword (void) or
they have a closer relationship?
As most others have said, it is just reuse of the keyword.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
.
- Follow-Ups:
- Re: void vs void* (philosophical question)
- From: Keith Thompson
- Re: void vs void* (philosophical question)
- From: Kenneth Brody
- Re: void vs void* (philosophical question)
- References:
- void vs void* (philosophical question)
- From: Giannis Papadopoulos
- void vs void* (philosophical question)
- Prev by Date: Re: Application Reading Itself
- Next by Date: Re: So what Standard are we working off?
- Previous by thread: Re: void vs void* (philosophical question)
- Next by thread: Re: void vs void* (philosophical question)
- Index(es):
Relevant Pages
|