# command-line-arguments
./runner.go:12:33: cannot convert 4 < 4.5 (untyped bool constant true) to type float64
Root cause
The root cause is the failure of automatic implicit Bool to Float conversion when the conversion output is added with a floating-point number in C, leading to a type mismatch error in Go. But, CxGo is successful at automatic implicit Bool to Float conversion when the conversion output is added with an integer in C.
Expected Code
Instead of local_float += float32(float64(4 < 4.5) + 3.5), my modification is local_float += float32(float64(int(libc.BoolToInt(4 < 4.5))) + 3.5)
And this works fine
Original C code
Converted Go Code
Go compiler error
Root cause
The root cause is the failure of automatic implicit
Bool
toFloat
conversion when the conversion output is added with a floating-point number in C, leading to a type mismatch error in Go. But,CxGo
is successful at automatic implicitBool
toFloat
conversion when the conversion output is added with an integer in C.Expected Code
Instead of
local_float += float32(float64(4 < 4.5) + 3.5)
, my modification islocal_float += float32(float64(int(libc.BoolToInt(4 < 4.5))) + 3.5)
And this works fine