1
votes

I have the following code in an iOS app, which uses the Accelerate framework:

 NSUInteger radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5);
            if (radius % 2 != 1) {
                radius += 1; // force radius to be odd so that the three box-blur methodology works.
            }
            vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend);

Xcode is showing a warning on the last line:

Implicit conversion loses integer precision: 'NSUInteger' (aka 'unsigned long') to 'uint32_t' (aka 'unsigned int')

Can I replace NSUInteger with uint32_t, even though I am converting the rest of this project to 64 and 32 bit safe code (mostly NSInteger instead of int, and the resulting method definition changes).

If not, how do I resolve the issue with NSUInteger?

1
There's nothing about fixed-size integer types that isn't "64 and 32 bit safe". What hypothetical issue are you worried about? - Stephen Canon

1 Answers

3
votes

You have two options:

  1. Change radius to uint32_t instead of NSUInteger.
  2. If you know that radius will never be too big, cast radius to uint32_t in the call to vImageBoxConvolve_ARGB8888.