1
votes

Code:

#define ASSERT_INDEX_IS_WITHIN_BOUNDS(idx,array)
    NSAssert2(idx >= 0 && idx <= (self.array.count-1), @"index %d beyond bounds [0 .. %d]", idx, (self.array.count-1))

The above macro causes the following warning:

Values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead.

This is in third party code and there are LOADS of these. How do I silence/fix them?

2
build only for 32-bit? - Michael Dautermann
@MichaelDautermann Targeting iPhone 5S. - duci9y
in the long run, it is always better to get them to be fixed ;) - Daij-Djan
@Daij-Djan - But even if we can find "them", is that legal? Would "they" include Kernighan and Ritchie? - Hot Licks

2 Answers

3
votes

You can still run the app on an iPhone 5S building it for 32-bit only, because the iPhone 5S will run existing 32-bit apps. Many apps will need to wait to start building for 64-bit until library vendors update their code to fix 64-bit issues, and in the case of static libraries to even include a 64-bit build of their code.

There's not really any reason you would absolutely need your code to run in 64-bit right now that I can see, and even if you did, you couldn't guarantee the stability of the third party libraries you're using. So I would suggest you, for the time being, stick with building 32-bit only, and it will run just fine on an iPhone 5S.

If you for some reason did absolutely need to be able to build your app for 64-bit, you'll either have to get the library vendor to update their code, or you'll have to remove it and write your own code to handle what theirs was doing.

EDIT:

To fix this exact warning, in the spots where it has %d, replace them with %lu.

0
votes

Using NSInteger/NSUInteger may solve your implicit conversion warnings.

I had been using int/long types in my code. If you need to support both 32bit and 64bit processors, this is one way to resolve this

#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
    typedef long NSInteger;
    typedef unsigned long NSUInteger;
#else
    typedef int NSInteger;
    typedef unsigned int NSUInteger;
#endif

As you can see from the NSObjCRuntime.h it converts the NS types to unsigned/signed int/long based on the LP64 (64bit) flag

hope that helps.