Top "Unsafe-pointers" questions

Some "safe" languages like Swift and Go offer "unsafe" pointers for use with APIs written in languages like C and Objective-C. Questions using this tag should also have the relevant language tag, e.g. [swift] or [go].

How to cast self to UnsafeMutablePointer<Void> type in swift

Trying to pass "self" to a C function in swift, when calling following code: var callbackStruct : AURenderCallbackStruct = AURenderCallbackStruct.init( inputProc: …

swift pointers casting unsafe-pointers
Getting pointer for first entry in an array

I want to get pointer of first entry in the array. This is how I tried int[] Results = { 1, 2, 3, 4, 5 }; unsafe { int* …

c# unsafe-pointers
Swift 3 UnsafePointer($0) no longer compile in Xcode 8 beta 6

My code snipet as follows …: let defaultRouteReachability = withUnsafePointer(to: &zeroAddress) { SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0)) } … does no longer compile with the …

swift3 unsafe-pointers xcode8-beta6
UnsafePointer<UInt8> initializer in Swift 3

I have a receipt validation class that is deprecated since Swift 3 has released. I fixed some issues, but I still …

ios swift3 unsafe-pointers
Swift 5.0: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(...)

I previously used this code in Swift 4.2 to generate an id: public static func generateId() throws -> UInt32 { let …

swift deprecated unsafe-pointers
How to get bytes out of an UnsafeMutableRawPointer?

How does one access bytes (or Int16's, floats, etc.) out of memory pointed to by an UnsafeMutableRawPointer (new in …

swift unsafe-pointers
Converting an UnsafePointer with length to a Swift Array type

I'm looking for the simplest ways to achieve reasonable C interoperability in Swift, and my current block is converting an …

c arrays swift unsafe-pointers
How to access unexported struct fields

Is there a way to use reflect to access unexported fields in Go 1.8? This no longer seems to work: https://…

go reflection unsafe-pointers
Cannot assign value of type UnsafeMutablePointer ObjCBool in Swift

I'm unfamiliar with Objective C. I'm using a private framework and need to be able to change one of the …

objective-c swift pointers casting unsafe-pointers
Pointers in Swift

I'm trying to understand the use of pointers in Swift, in particular: Unsafe[Mutable]Pointer and UnsafeRaw[Mutable]Pointer. I …

swift pointers unsafe-pointers unsafemutablepointer