cgo C.uint64_t compatiblity on multiple platforms?

117 views
Skip to first unread message

David Stainton

unread,
Dec 3, 2022, 1:51:18 PM12/3/22
to golang-nuts
Greetings,

I think my question is something like: "how to make my usage of C.uint64_t work on all platforms?" or "Is there something obviously wrong with my cgo bindings that is causing this not to build on all platforms?"

I wrote this cgo binding for the reference implementation of Sphincs+ (it's a hash based post quantum signature scheme):


Recently we noticed it fails to build on MacOS and Windows:


So I "fixed" it by changing the typecast to use C.uint64_t instead of C.ulong:


However that causes the build to fail using Go1.19.3 on MacOS, although it works on Windows:



Sincerely,
David Stainton

Dan Kortschak

unread,
Dec 3, 2022, 2:39:24 PM12/3/22
to golan...@googlegroups.com
The header file definition for crypto_sign_signature uses size_t for
the parameters that are passed as ulong in the calls that are causing
the issue. These types are not always the same size, so perhaps in e.g.
https://github.com/katzenpost/katzenpost/blob/a165cb2a13e40f3a15dd1fa296a7763d8b638ae0/sphincsplus/ref/binding.go#L120-L125
making the ulong params be size_t would help.

David Stainton

unread,
Dec 3, 2022, 8:22:58 PM12/3/22
to golang-nuts
Thanks, yes switching those type casts to C.size_t worked.
Reply all
Reply to author
Forward
0 new messages