tera
1
Is it possible to suppress this warning?
class C {}
struct S {
var i = 0
var c = C()
}
var a = S()
func foo(_ v: UnsafeRawPointer) {}
foo(&a)
// 🔶 Warning: Forming 'UnsafeRawPointer' to a variable of type 'S';
// this is likely incorrect because 'S' may contain an object reference.
AlexanderM
(Alexander Momchilov)
2
Can you use the scoped withUnsafePointer API?
class C {}
struct S {
var i = 0
var c = C()
}
var a = S()
func foo(_ v: UnsafeRawPointer) {}
withUnsafePointer(to: &a) { p in
foo(p)
}
2 Likes