So your C normalize
macro assigns c
to a
if a
is not equal to 0xffffffff
, or to 0
otherwise. I'm not sure what kind of normalization it is, but it's not my concern now.
So given the Go function signature you provided, this would work:
func normalize(a uint32, c *uint32) {
if a != 0xffffffff {
*c = a
} else {
*c = 0
}
}
However, I'm not sure why not just return a value instead of writing it via c
pointer?
func normalize(a uint32) {
if a != 0xffffffff {
return a
}
return 0
}
Side note: the same applies to your C macro. By the way, the macro evaluates a
twice, this might come as a surprise if you ever pass some function with side effects as a
. Any reason not to use (inline) function instead of a macro, or at least make it so that it evaluates to a new value, instead of assigning c
to it?