Volume of variables

Why do local variables use Stack in C / C ++?

+3
source share
7 answers

Technically, C does not use the stack. If you look at the C99 standard , you will not find a link to the stack. This is probably the same for the C ++ standard, although I have not tested it.

Stacks are simply implementation details used by most compilers to implement C automatic storage semantics.

+6
source

. , , . , , . . , .

, , , - . , , .

Heaps , → , . , ,

+2

, : " C ++ ?"

, C, ++ , . :

6.2.4

1 , . : , . 7.20.3. 2 - , . , 25) . 26) , undefined. , , , . 3 , , static . - , .

4 , static .

5 , , , , , . ( , , .) , . . , , ; .

C, n1256.

, 5 , , , , , x86. , 5.

+2

, . "": D

, , , . , , .

+1

.

.

0

, . , "". "" .

0

, . , , .

When a jump occurs, local variables are pushed and a jump is performed. When you return back to the scope, local variables exit.

0
source

Source: https://habr.com/ru/post/1796081/


All Articles