Re: C stack / heap!?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



lee <funnyvoice@xxxxxxxxxxx> writes:

> Im looking for a more precise answer! ;)

This mailing list is really for using gcc.  You are asking a general C
programming language question.  I would encourage you to ask on a C
language forum rather than here.  It is likely that you will get
better answers.


> If I do this for example:
>
> int A[12];
>
> int main()
> {
>    int i = 0;
>     for( i =0; i < 12; i++)
>          A[i] = i+1;
>    return 0;
> }
>
>
>
> int main()
> {
> int A[12];
>    int i = 0;
>     for( i =0; i < 12; i++)
>          A[i] = i+1;
>    return 0;
> }
>
>
>
> where on the stack does A go? and which is faster?

In the first example A does not go on the stack at all.  In the second
example it is in the function's stack frame.  It is unlikely that
there will be any major speed difference between the two.


> I wanted to implement a ring buffer in C? but Im wondering if its
> faster to put the ring buffer array global or in a struct, or even
> into a c++ object?
> for example the boost circular ( ring buffers )....

It's very likely that all of those choices would execute with the same
speed.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux