I have a "MyConstants.h" file that is imported by several classes.
Inside that file I have things like:
static BOOL isIndexValid(NSInteger index) {
return ((index >=0) && (index < 200));
}
This function is extensively used by the classes importing MyConstants.h
. Even so, Xcode complains that this function and others are not used.
Why?
Defining a static
function (or variable, for that matter) in a header file means every source file that imports that header file will get its own copy.
That is not good and is what the compiler is complaining about (not every source file references this function).
Make it static inline
instead:
static inline BOOL isIndexValid(NSInteger index) {
return ((index >=0) && (index < 200));
}