How to remove 100s of warnings "implicit conversion loses its accuracy:" NSInteger "(aka" long ") to" int ", which I received after upgrading to arm64?

Problem:

Yesterday, I converted a large project to support arm64 , after which I immediately received 500+ warnings. About 70% of them are where the NSIntegerint is assigned or vice versa, and the rest where the NSUInteger is formatted NSStringas follows:

NSInteger a = 123;
NSString *str = [NSString stringWithFormat:@"Int:%d", a]; //warning: value of 'NSInteger' should not be used as formate argument; add an explicit cast to 'unsigned long' instead.

Now I know how to access them manually, but this is a huge task and very laborious. I also know that I can completely disable type mismatch warnings, but I don't want to do this. Of course, they are very useful.

What I tried:

  • I converted [NSNumber numberWithInt:abc];to [NSNumber numberWithInt:(int)abc];using find-n-replace. He fixed some.
  • I also tried changing all my int properties to NSInteger properties but it doubled the number of warnings (up to 900). So I'm back.

  • I also tried to find some kind of regular expression, but could not find something suitable for my needs.

Question:

I am looking for a regex or any other workaround that someone has tried, which may reduce the amount of work needed to fix them manually.

Thanks in advance.

+4
source share
3 answers

- , , . @Raju ( ), , , .

Apple script 64- ConvertCocoa64, /Developer/Extras/64BitConversion/ConvertCocoa64, int NSInteger, float CGFloat, :

int unsigned int NSInteger NSUInteger, . ints - . script .

, . .

. . , script, -64- .

+2
NSInteger a = 123;
NSString *str = [NSString stringWithFormat:@"Int:%ld", (long)a];

64 typecast ((long) a). % d 32- % ld . .

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Cocoa64BitGuide/ConvertingExistingApp/ConvertingExistingApp.html

+4

c "NSUInteger" ( "unsigned long" ) "int

Project > Build Setting " 32Bits Type > Debug > * 64 architecture: No"

Project > Build Setting "typecheck calls to printf/scanf: NO"

: [ ]

Check calls to printf and scanf, etc., to make sure that the arguments provided are of the type matching the specified format string, and that the conversions specified in the format string make sense.

Hope it works

[caution: this may invalidate another 64-bit architecture architecture warning).

0
source

All Articles