You should not use extern static
. You should only use extern
.
File.h
extern const int MyGlobalConstant; // NOTE: Not static
File.m
const int MyGlobalConstant = 12345; // NOTE: This is not static either
This creates a memory location in File.m
which other files that import File.h
can reference.
In contrast,
File.h
static const int MyGlobalConstant = 12345;
This creates a separate and distinct memory location in every .m file which includes File.h
.
The difference is important. In the first example, you have 1 MyGlobalConstant
. In the second example, you will have tens if not hundreds of separate MyGlobalConstant
s all with the same value.
It's more than just a waste of space. I can cause problems debugging and problems for a profiler.