Unknown parameter UInt8 in '_specialize attribute': Xcode 9
Asked Answered
B

1

5

This code used for building bit pattern from array of bits gives me error in Xcode 9 (works in 8.3.3)

@_specialize(UInt8)
func integerFrom<T: UnsignedInteger>(_ bits: Array<Bit>) -> T {
    var bitPattern: T = 0
    for idx in bits.indices {
        if bits[idx] == Bit.one {
            let bit = T(UIntMax(1) << UIntMax(idx))
            bitPattern = bitPattern | bit
        }
    }
    return bitPattern
}

Error

Unknown parameter UInt8 in '_specialize attribute'

Any leads/suggestion on this?

Bickering answered 14/6, 2017 at 7:7 Comment(4)
@GoJava The expected behavior of function is already given in comment above the function ("build bit pattern from array of bits"). Thanks for the tip though, I will make it more explicit.Bickering
Sorry I did not see that(comment removed). Thank you for editing :)Pert
what is the reason for @_specialize attribute in your code? @_specialize currently acts as a hint to the optimizer ... do you really need this here? if you are sure that you need it, use @_specialize(where T == UInt8) for swift 3.2Gobbledygook
I recognize this code. You can either remove private specialization attribute or update to Swift 4 syntax with @_specialize(where T == UInt8)Sousaphone
E
10

You just need to include a where clause in the specialize definition like this

@_specialize(where T == UInt8)
Enure answered 7/9, 2017 at 17:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.