Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are global variables in C automatic variables?

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.

like image 1000
Michael Avatar asked Nov 27 '25 17:11

Michael


1 Answers

No, these concepts don't play each other. The term global variable is an informal notion, that refers to variables with external linkage. By definition, the automatic variables have no linkage, hence it does not make sense to have variable, that is both automatic and global.

like image 128
Grzegorz Szpetkowski Avatar answered Nov 30 '25 07:11

Grzegorz Szpetkowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!