Extern is the global variable declaration. As long as the global variable is declared, extern is added first by default (the programmer can not add it, but the compiler adds it by default)
If this file references global variables in other files, you must add the extern declaration.
By default, the function has extern before its declaration and definition. For example, when we declare a function,
Int Foo (INT arg1, char arg2 );
There is an implicit extern before the function, and the compiler processes it
Extern int Foo (INT arg1, char arg2 );
The definition of global variables is generally placed in the source file. If it is placed in the header file, it is likely that the definition will be repeated.
After a global variable is defined, you can place the declaration in the corresponding source file, and other files can include the header file when using the variable.
If you do not want to include the variable (you only want to use this variable and do not need to include it), you can declare this variable using extern.
Global variables and global functions are defined with extern by default. Even if the programmer does not add it, the compiler will add it.