lemme in@lemm.ee to Programming@programming.dev · 11 days agoThe US government wants devs to stop using C and C++www.theregister.comexternal-linkmessage-square77fedilinkarrow-up1216arrow-down119
arrow-up1197arrow-down1external-linkThe US government wants devs to stop using C and C++www.theregister.comlemme in@lemm.ee to Programming@programming.dev · 11 days agomessage-square77fedilink
minus-squareScreaminOctopuslinkfedilinkEnglisharrow-up5·10 days agoIn my understanding, you can’t interface with the C abi without using an unsafe block.
minus-squareFizzyOrange@programming.devlinkfedilinkarrow-up1·10 days agoI think there are some crates that wrap the unsafe code for you, e.g. https://github.com/rodrimati1992/abi_stable_crates/ (I haven’t ever tried it).
minus-squarecalcopiritus@lemmy.worldlinkfedilinkarrow-up1arrow-down1·9 days agoYou can just use an unsafe block though. Or make a thin wrapper that is just safe functions that inside just have an unsafe block with the C ABI function. Even if rust had a stable ABI, you would still need that unsafe block.
In my understanding, you can’t interface with the C abi without using an unsafe block.
I think there are some crates that wrap the unsafe code for you, e.g. https://github.com/rodrimati1992/abi_stable_crates/ (I haven’t ever tried it).
You can just use an unsafe block though. Or make a thin wrapper that is just safe functions that inside just have an unsafe block with the C ABI function.
Even if rust had a stable ABI, you would still need that unsafe block.