Open Yeaseen opened 3 months ago
Thank you for example. Not every C features are implemented in C4Go, because (I hope) it is not popular programming writing approach:
mystruct test_bool(int inp){
return (mystruct){.intM = inp != 0};
}
The legacy C codebase includes this feature. However, if a transpiler like c4go is used to translate the C code to Go, it will fail. After all, this is the task of a transpiler to convert legacy code to memory-safe modern languages
Source C code
C code's output
Translated Go code by
c4go
Go compiler build error
Root Cause
c4go
fails to convert boolean expression to Integer in Struct initializationModified Go code that works
I modified the initialization so that it could use
noarch.BoolToInt
function. And it gives the outputs as the source C code does.Instead of
return mystruct{inp != 0}
, my modification isreturn mystruct{noarch.BoolToInt(inp != 0)}
Output after modification