Re: [Newbie] What is sizeof() ?

From: Christian Bau (christian.bau_at_cbau.freeserve.co.uk)
Date: 10/31/03


Date: Fri, 31 Oct 2003 01:01:44 +0000

In article <11iob.922$eV1.240@newsfep1-gui.server.ntli.net>,
 "Peter Pichler" <pichlo6@pobox.sk> wrote:

> "Vincent Pierroux" <VPierroux@cybernet.be.SPAM> wrote in message
> news:3fa17e49$1_8@corp.newsgroups.com...
> > So, if it is a operator i don't have any argument push on the stack like a
> > function.
> >
> > If i make onething like that
> >
> > for(foo=0;foo<1000;i++)
> > foo+= sizeof myStruct ;
> >
> > it take the same processing time this
> >
> > var= sizeof myStruct
> > for(foo=0;foo<1000;i++)
> > foo+= var;
>
> Most likely the first one will take shorter: sizeof myStruct is a constant,
> so the compiler might just replace the whole loop with
>
> foo += 1000 * sizeof myStruct;
>
> On the other hand, so it could in the second case, should it be clever
> enough.

You mean stupid enough? Take a very good look at the for loop. It is
most likely _not_ executed 1000 times.



Relevant Pages

  • Re: Compilers, Aho/Sethi/Ullman, Exercise 2.15
    ... For example if j = 5 before the loop, ... push v onto the stack ... lvalue l... ... throw away value on top of stack ...
    (comp.compilers)
  • Re: Virtual machine: assembly instructions
    ... push; Push the address of the first variable onto the stack ... jmpzero loopStart; ... This seems like pretty good code, assuming that the code inside the loop ...
    (comp.programming)
  • Re: Newbie question stack implementation
    ... > would like to pop them and print them out as they come off the stack. ... int main ... In that case push() ... would work correctly you still would have a problem with this loop - ...
    (comp.lang.c)
  • Re: DISFAVORED Was: name for 3 PICK finally?
    ... No complication except having a pool for stack variables, ... I felt like it was nice to have a loop ... I also have a defining word called PLURAL which I use to make plurals ... actually need any headerless definitions, ...
    (comp.lang.forth)
  • Re: Toward a Forth thats easier to learn
    ... And yet you're advocating an approach to software that shuts all but the ... the return stack that users use be independent of the loop stack is a ... getting them to understand that loop items are on the return stack), ... and another range that stayed cells. ...
    (comp.lang.forth)