elliotchance / c2go

⚖️ A tool for transpiling C to Go.
MIT License
2.07k stars 154 forks source link

unknown node type: 'DLLImportAttr 0x23f806baea8 <col:18>' #799

Open silbinarywolf opened 5 years ago

silbinarywolf commented 5 years ago

Operating system

What I did I added a #define _GLFW_WIN32 to win32_init to workaround the #error pragma throwing and then got the following error.

c2go transpile glfw/src/win32_init.c
panic: unknown node type: 'DLLImportAttr 0x1a818906e98 <col:18>'

goroutine 28 [running]:
github.com/elliotchance/c2go/ast.Parse(0xc0016a5258, 0x24, 0x6af74c, 0x5)
        D:/GoProjects/src/github.com/elliotchance/c2go/ast/ast.go:270 +0x431b
main.convertLinesToNodes(0xc0005df650, 0x47b3, 0x8f66, 0x0, 0x0, 0x0)
        D:/GoProjects/src/github.com/elliotchance/c2go/main.go:89 +0x1d6
main.convertLinesToNodesParallel.func1.1(0xc00004a240, 0xc000006008, 0xc0005df650, 0x47b3, 0x8f66, 0x0)
        D:/GoProjects/src/github.com/elliotchance/c2go/main.go:113 +0x60
created by main.convertLinesToNodesParallel.func1
        D:/GoProjects/src/github.com/elliotchance/c2go/main.go:111 +0x119

Source: https://github.com/go-gl/glfw/blob/master/v3.2/glfw/glfw/src/win32_init.c

What I'm trying to achieve Im experimenting with this tool to see how feasible it is to remove cgo from the go-gl packages gl and glfw.

https://github.com/go-gl/gl/issues/109

elliotchance commented 5 years ago

This is because we haven't done very much testing against windows and you have discovered a new AST node type that c2go doesn't know how to handle.

Here is an example of how to fix it: https://github.com/elliotchance/c2go/pull/773

silbinarywolf commented 5 years ago

Thanks for the example, I might have a poke around and play with this sometime this week!

Konstantin8105 commented 5 years ago

Dear @silbinarywolf , Please try project https://github.com/Konstantin8105/c4go