Re: void vs void* (philosophical question)



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.
.



Relevant Pages

  • Re: Can Class be Inter-refferenced?
    ... Someone who knows the C++ standard would have to check, ... is because when the function is called the size of ClassB must be known ... I think passing an incomplete type would only be a problem ... me as passing the object as a const & is generally preferred. ...
    (microsoft.public.vc.language)
  • Re: structure containing incomplete array type
    ... >> Is a structure containing an incomplete array as its last element (per ... >> incomplete type? ... Those words don't appear in the standard, although they do in draft ...
    (comp.lang.c)
  • Re: "Referenced type "
    ... An incomplete type is a type. ... I have no idea what "usual claptrap" you're talking about. ... standard says in a positive manner what it is. ... replacement of the term into the English language. ...
    (comp.lang.c)
  • Re: Template instantiation of std::list<> with incomplete type
    ... > is related to standard library, ... I've seen some STL implementations which allow this ... used to instantiate standard library template components), ... if an incomplete type is used as a template argument when ...
    (comp.lang.cpp)