extern
keyword
Not sure if this exists in C++. Saw it in the Clean Architecture book.
Resources
the extern keyword extends the visibility of the C variables and C functions. That’s probably the reason why it was named extern.
https://stackoverflow.com/questions/3684450/what-is-the-difference-between-static-and-extern-in-c
static
vs.extern
?
static
 means a variable will be globally known only in this file.Âextern
 means a global variable defined in another file will also be known in this file, and is also used for accessing functions defined in other files.
So basically
static
has the file scopeextern
has the entire program scope
Therefore, this only declares it, not define it.
- Will not compile because
var
’s value is overwritten even though it’s never declared
This works