Reputation: 35933
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?
Upvotes: 5
Views: 2217
Reputation: 5152
Try to insert __unused
between return type and function name, and it works for me on Xcode 10.2
static BOOL __unused isIndexValid(NSInteger index) {
return ((index >=0) && (index < 200));
}
Hope it will be helpful for you.
Upvotes: 1
Reputation: 9721
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));
}
Upvotes: 9