Thread overview | |||||
---|---|---|---|---|---|
|
May 23, 2007 void size | ||||
---|---|---|---|---|
| ||||
The program import std.stdio; import std.string; void main () { writefln("Sizeof(void)="~toString(void.sizeof)); } compiles and outputs "sizeof(void)=1". Is this supposed to happen? I mean, in C, it is an error to request sizeof(void) (compiler fails). |
May 23, 2007 Re: void size | ||||
---|---|---|---|---|
| ||||
Posted in reply to orgoton | orgoton wrote: > The program > > import std.stdio; > import std.string; > > void main () > { > writefln("Sizeof(void)="~toString(void.sizeof)); > } > > compiles and outputs "sizeof(void)=1". Is this supposed to happen? I mean, in C, it is an error to request sizeof(void) (compiler fails). Yes, it is supposed to happen. I can't find a Walter quote or documentation for it, but IIRC void.sizeof is defined as 1 in order for void arrays to work properly. -- Remove ".doesnotlike.spam" from the mail address. |
May 23, 2007 Re: void size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Deewiant | "Deewiant" <deewiant.doesnotlike.spam@gmail.com> wrote in message news:f31fg3$57$1@digitalmars.com... > > Yes, it is supposed to happen. I can't find a Walter quote or > documentation for > it, but IIRC void.sizeof is defined as 1 in order for void arrays to work > properly. > I want to say it's defined as the smallest addressable type on the system. Like you said, I don't remember where that was mentioned. |
Copyright © 1999-2021 by the D Language Foundation