2017-09-22 65 views
0

我已經安裝了一個叫做'SwiftProtobuf'的Cocoapod,但是它出現了這個錯誤'Integer literal'9223372036854775808'當存儲到'Int'時溢出錯誤發生在這個函數中:Swift Protobuf中的錯誤消息CocoaPods

 if n >= 0x8000000000000000 { // -Int64.min 
      if n > 0x8000000000000000 { 

這裏的整體功能:

internal mutating func nextSInt() throws -> Int64 { 
    if p == end { 
     throw TextFormatDecodingError.malformedNumber 
    } 
    let c = p[0] 
    if c == asciiMinus { // - 
     p += 1 
     // character after '-' must be digit 
     let digit = p[0] 
     if digit < asciiZero || digit > asciiNine { 
      throw TextFormatDecodingError.malformedNumber 
     } 
     let n = try nextUInt() 
     if n >= 0x8000000000000000 { // -Int64.min 
      if n > 0x8000000000000000 { 
       // Too large negative number 
       throw TextFormatDecodingError.malformedNumber 
      } else { 
       return Int64.min // Special case for Int64.min 
      } 
     } 
     return -Int64(bitPattern: n) 
    } else { 
     let n = try nextUInt() 
     if n > UInt64(bitPattern: Int64.max) { 
      throw TextFormatDecodingError.malformedNumber 
     } 
     return Int64(bitPattern: n) 
    } 
} 

回答

0

我曾經爲0xffffffff作爲作爲UInt32的和錯誤走了。