4 ms·
So it’s not possible to interface with Metal or the Accelerate framework on macOS using pure C? I’ve found some outdated C wrappers for metal but nothing up to
by OliverM 5y ago
So it’s not possible to interface with Metal or the Accelerate framework on macOS using pure C? I’ve found some outdated C wrappers for metal but nothing up to date, and wondered if something in the later versions assumed Swift or Objective C library consumption…
- comex 5y agoAccelerate is a pure C API. Metal is an Objective-C API. It is possible to call arbitrary Objective-C APIs from pure C using the Objective-C runtime functions, and Apple themselves recently released a Metal API wrapper written in C++ that works this way. [1] I wouldn't recommend that approach, though. With Objective-C being an almost-pure superset of C, it's a lot easier to just build your code in Objective-C mode and make native Objective-C calls where necessary. [1] https://news.ycombinator.com/item?id=29289761 https://news.ycombinator.com/item?id=29289761
- flohofwoe 5y agoTheoretically, Metal can be called from C by going directly through the Objective-C runtime API, but this requires either macro magic (like: https://github.com/garettbass/oc/ https://github.com/garettbass/oc/), or code-generated headers (which was most likely used in the official Metal-cpp wrapper: https://developer.apple.com/metal/cpp/ https://developer.apple.com/metal/cpp/) But it's not a big deal to move all the ObjC code into a separate .m source file and expose a smaller and higher level C API.