3

I was studying ANSI C programming language and it says in introduction:

"Local variables are typically "automatic," or created anew with each invocation."

I'm guessing allocating and deallocating variables work with stack frame logic of Java. So are global variables automatic too? They would get in and out of stack frame much less than local variables since they are in the scope of the whole .c file.

4

1 回答 1

2

不,这些概念不会相互影响。术语全局变量是一个非正式的概念,指的是具有外部链接的变量。根据定义,自动变量没有链接,因此拥有变量是没有意义的,即既是自动的又是全局的。

于 2016-11-04T21:19:28.117 回答