Skip to content

Instantly share code, notes, and snippets.

View devahmedshendy's full-sized avatar

Ahmed Shendy devahmedshendy

  • Egypt
View GitHub Profile
@devahmedshendy
devahmedshendy / DynamicFunctions.swift
Created February 28, 2024 00:23 — forked from neonichu/DynamicFunctions.swift
Using dlopen / dlsym to call C functions from Swift
import Darwin
let handle = dlopen("/usr/lib/libc.dylib", RTLD_NOW)
let sym = dlsym(handle, "random")
let functionPointer = UnsafeMutablePointer<() -> CLong>(sym)
let result = functionPointer.memory()
println(result)