2

I have upgraded my Xcode version from 5.0 to 5.1 & started occuring below error in GPUImage Library GPUImageVideoCamera.m:301:54: Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int32_t' (aka 'int')

In below function on this line "connection.videoMaxFrameDuration = CMTimeMake(1, _frameRate);" error is occuring.

- (void)setFrameRate:(NSInteger)frameRate;
{

    _frameRate = frameRate;

    if (_frameRate > 0)
    {

        for (AVCaptureConnection *connection in videoOutput.connections)
        {

            if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)])

                connection.videoMinFrameDuration = CMTimeMake(1, _frameRate);

            if ([connection respondsToSelector:@selector(setVideoMaxFrameDuration:)])

                connection.videoMaxFrameDuration = CMTimeMake(1, _frameRate);

        }
    }

    else

    {
        for (AVCaptureConnection *connection in videoOutput.connections)

        {
            if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)])

                connection.videoMinFrameDuration = kCMTimeInvalid; 
                                // This sets videoMinFrameDuration back to default

            if ([connection respondsToSelector:@selector(setVideoMaxFrameDuration:)])

                connection.videoMaxFrameDuration = kCMTimeInvalid; 
                                // This sets videoMaxFrameDuration back to default

        }
    }
}

enter image description here

Dattatray Deokar
  • 1,923
  • 2
  • 21
  • 31
  • In Xcode 5.1 64 bit architectures are enabled by default. This should not be an error but just a warning. To get rid of the warning you can add explicit casts or update the Library. – carloabelli Mar 14 '14 at 06:08
  • 1
    Xcode treating it as an error – Dattatray Deokar Mar 14 '14 at 06:09
  • 1
    @DattatrayDeokar: Perhaps you have set the build setting "Treat warnings as errors" set to YES. - As said in above comment, just add an explicit cast, or change the type of _frameRate from NSInteger to int. – Martin R Mar 14 '14 at 06:17

1 Answers1

9

The problem is related with architecture. If you open your existing project in Xcode 5.1, It's default arch setting is 64-bit architectures.

See this lines in Xcode 5.1 release nots

Note: Be aware of the following architectures issues when opening your existing projects in Xcode 5.1:

  • When building for all architectures, remove any explicit architectures setting and use the default Standard Architectures setting. For projects that were previously opted-in using “Standard Architectures Including 64-Bit”, switch back to the “Standard architectures” setting.
  • When opening an existing project for the first time, Xcode 5.1 may display a warning about the use of the Xcode 5.0 architectures setting. Selecting the warning provides a workflow to revise the setting.
  • Projects not able to support 64-bit need to specifically set the architectures build setting to not include 64-bit.

You can see this line in this apple's doc.

NSInteger changes size in 64-bit code. The NSInteger type is used throughout Cocoa Touch; it is a 32-bit integer in the 32-bit runtime and a 64-bit integer in the 64-bit runtime. So when receiving information from a framework method that takes an NSInteger type, use the NSInteger type to hold the result.

But int is a 32-bit integer, so only this arise this error. You can solve this problem by setting architecture to standard architecture including 64-bit or do simple type casting as below.

connection.videoMinFrameDuration = CMTimeMake((int64_t)1, (int32_t)_frameRate);

See CMTimeMake syntax.

CMTime CMTimeMake (
   int64_t value,
   int32_t timescale
);
Mani
  • 17,549
  • 13
  • 79
  • 100
  • Current settings are the same as you suggested standard architecture including 64-bit – Dattatray Deokar Mar 14 '14 at 06:17
  • Mani probably meant to *exclude* 64-bit from the architectures. But there is no need for this as this problem is easily solvable with an explicit cast or change of data types. – Martin R Mar 14 '14 at 06:18
  • @MartinR Yes. You are right. I missed with my answer – Mani Mar 14 '14 at 06:20
  • @DattatrayDeokar then according to your setting, this problem also arised in Xcode 5 too. Am I right? – Mani Mar 14 '14 at 06:23
  • Yes, now i have typecasted and resolved the issue. My concern behind asking Question is that if i am missing precision value by typecast then it will affect on functionality – Dattatray Deokar Mar 14 '14 at 06:27
  • No. In this case, It should not affect functionality. – Mani Mar 14 '14 at 06:29
  • @Mani: Unless I am mistaken, the correct cast would be `CMTimeMake(1, (int32_t)_frameRate)` . – Martin R Mar 14 '14 at 06:44
  • @MartinR According to comment with Dattatray Deokar, his issue was resolved But your point is absolutely correct. Wait I'll update my answer. – Mani Mar 14 '14 at 06:56