cbool(b) feels just as good as bool(b) in those terms.
That said, it may be a good idea to have a C.CBool(b bool) int helper available.
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/blog
http://niemeyer.net/twitter
Ah, ok, that's another topic indeed. Go doesn't allow implicit
cross-type casting, so while in Go land, cgo logic will behave as Go
code should.
We can make a C.CBool(b) operation be a NOOP, but you're right, you're
early optimizing if you're worried about this before you have a speed
problem at all.
Hello,
You are right, the function call is not more verbose than the cast. I
misspoke. I really object to the requirement of a function call. A
conversion that would be essentially free on a C compiler, now
requires a function call plus a branching statement. I'm probably
micro-optimizing, but this just seems unnecessary.
In any case, I suspect that this is a common task for CGO users. I
figured that there would be a standard approach.
Robert