The term used in C programming is "file scope." Variables declared outside of all functions, and functions themselves, are considered to be "objects with file scope."
However, there's a little more to it than that.
C has two ideas you have to keep in mind: scope and linkage. They are different, but they interact with each other.
C defines three categories of linkage: external linkage, internal linkage, and no linkage. The first two are fairly simple: a symbol with file scope and external linkage is visible to other files. A symbol with file scope and internal linkage is not visible to other files but is visible inside the file where it is defined/declared. A symbol with file scope and no linkage is also not visible to other files. The main difference between no linkage and internal linkage is magic. Things like typedefs have no linkage -- mainly object types that "exist" in the compiler but "don't exist" when the object file is written. NOTE: beware of C++. There are a lot more different kinds of objects that have no linkage in C++ (like const objects). So rules that you read which are written for C++ may be false for C.
By default, a symbol that is defined at file scope has external linkage:
Code:
int A = 0;
void foo(void) {
printf("foo!\n");
}
Both the variable 'A' and the function 'foo' have file scope and external linkage here.
You can declare that a file scope symbol with external linkage is defined someplace else using the extern keyword:
Code:
extern int A;
extern void foo(void);
This is common in header files.
You can "just declare" a function, and it's okay to define it later. Likewise, if you declare a variable but do not initialize the declaration, it's similar to an extern (there are some finicky details, though):
Code:
int A; // declared, not initialized
void foo(void); // prototype declaration, not a definition
Finally, you can force internal linkage using the static keyword. This makes the declared/defined symbols invisible from outside (sort of):
Code:
static int A = 0; // defined, but with internal linkage
static void foo(void) {
printf("foo, but only from within this file!\n");
}
Note: "static" and "linkage" can be complicated because this all relates to the object file format and CPU hardware and operating system being used. The objective in C is to accomplish that which is promised: to make symbols visible/invisible to other translation units. However, in a large enough program it may be impossible to write an object module without creating an entry for static symbols. Thus, a symbol marked as static may still get an entry in the object file's symbol data, and so might be visible to other tools. Usually in this case the compiler adopts a convention, like "extern symbols have a leading underscore while static symbols don't" that helps to avoid conflicts, but the symbol might still be visible.