How a static variable does not get reassigned when inside a function

I have a question regarding the answer in this question, but I can not comment on it because I have less than 50 representatives.

I was interested in the answer being foo()called several times, and a static variable is assigned the same number of times. So why isn't a static variable reassigned to 10 each time?

+6
source share
3 answers

In fact, variables staticcan get reassigned . But it cannot be redefined .

static . .

+1

, .

. " " ( ).

- , static. , , C11, ยง6.2.4.

2

- , . , . [....]

, .

, , 3,

, _Thread_local, , static, . - , .

, , , ( ), . .

+3

, , , , . , , , . , , , , , .

0

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


All Articles