On Wed, 24 Dec 2014 00:24:44 +0000
FrankLike via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
wrote:

> On Tuesday, 23 December 2014 at 20:22:12 UTC, ketmar via 
> Digitalmars-d-learn wrote:
> > On Tue, 23 Dec 2014 15:37:12 +0000
> > FrankLike via Digitalmars-d-learn 
> > <digitalmars-d-learn@puremagic.com>
> > wrote:
> >
> >> you will find the different:
> >>   D: PROCESSENTRY32* pe32 = 
> >> cast(PROCESSENTRY32*)GC.calloc(PROCESSENTRY32.sizeof);
> >> 
> >> C++:PROCESSENTRY32 pe32;
> >> 
> >> GC.calloc means: memset ?!
> >
> > do you see that shining star there? here it is, right in the 
> > end:
> > `PROCESSENTRY32*`. and do you see that same star in C sample?
> 
> Yes,if you not do like it,it  will  not  work.
> 
> > jokes aside, it's dead simple: C code using stack-allocated
> 
> Not joke.it works fine,you can  run  it.
> Not  C,it's  C++.
> > struct
> > (`PROCESSENTRY32` without an inderection) and D code using
> > heap-allocated struct (`PROCESSENTRY32*` with indirection).
> >
> > hence C code using `memset()`, yet D code using `GC.calloc()`.

you did quoted the relevant part. let me repeat it:

C code using stack-allocated struct (`PROCESSENTRY32` without an
inderection) and D code using heap-allocated struct (`PROCESSENTRY32*`
with indirection).

hence C code using `memset()`, yet D code using `GC.calloc()`.

i.e. D code using *pointer* *to* *struct*, so you must allocate it
manually.

Attachment: signature.asc
Description: PGP signature

Reply via email to