New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support function pointers #157
Comments
C
Suggested Go
Now I need to find out how to get from C to Go. This may not cover all cases... |
You should not need to create an interface. You can just convert the function pointer directly to it's equivalent type, for example:
To fix this you will just need to teach Within a single function pointer you can use the resolve to convert each data type (of the parameters and return). |
I have the C example above working by hard-coding "int (int, int)" in a few places, hard-coding the Go AST... I now need to make it work with other return types and parameters. The changes are affecting:
I will keep working on this. Go output: (no c2go warnings)
|
@yulvil The output looks perfect. Did you manually write that or was that the output of c2go? |
@elliotchance The Go file was generated by c2go. I only implemented the Work in progress: |
I am hoping to finish implementing this over the weekend. |
@yulvil , Excuse, I found your message, but too later - I create PR. Excuse me again. |
@elliotchance @Konstantin8105 I do no think that the functionality is complete. We should reopen this issue.
https://github.com/elliotchance/c2go/blob/master/types/resolve.go#L226,L231
TODO:
Example:
Current go output (not compiling)
go build main.go
|
Some of these larger tasks should really be multiple issues so that we can provide the functionality in useful stages. Especially when "done" isn't an absolute measurement. Also there will always be cases where some edge case is not covered. Thanks for providing that information, I've reopened this issue. I'll be sure to pay attention to when issues should really be broken down to something more specific. That's my bad since I opened this issue originally. |
Present output: /*
Package main - transpiled by c2go version: v0.21.10 Zinc 2018-02-14
If you have found any issues, please raise an issue at:
https://github.com/elliotchance/c2go/
*/
package main
import "os"
var f func(int, float32, float64) float64
// add - transpiled function from /home/konstantin/go/src/templorary/6.c:3
func add(a int, b float32, c float64) float64 {
return c
}
// mul - transpiled function from /home/konstantin/go/src/templorary/6.c:7
func mul(a int, b float32, c float64) float64 {
return c
}
// main - transpiled function from /home/konstantin/go/src/templorary/6.c:11
func main() {
f = add
f(3, float32(4), float64(5))
f = mul
os.Exit(int(f(3, float32(4), float64(5))))
}
func init() {
} That issue can be closed. |
No description provided.
The text was updated successfully, but these errors were encountered: