I have gone through following two questions:
static and extern global variables in C and C++
global variable in C are static or not?
Both questions says the two things in different way.
Question 1's Answer:
Global variables are not extern nor static by default on C and C++.
Question 2's Answer:
If you do not specify a storage class (that is, the extern or static keywords), then by default global variables have external linkage
I need to know the following:
- Are global variables
extern
by default in linkage (or) is it equivalent to declaring variables by specifyingextern
storage class? - Are global variables
static
by default in scope (or) is it equivalent to declaring variables by specifyingstatic
storage class? - Is there any difference with
C
orC++
? Can anyone please clarify?