Comments (12)
Hi @carstenhag - this is almost certainly due to processing different header files that c2go cannot understand. The compiler environments are slightly different from those I've tested with my mac, ubuntu 14.04 and travis builds.
I realise the error is confusing, the error messages will become more useful over time. This specific error is caused by it trying to translate a C type into the equivalent Go type. Like unsigned int
(C) -> uint32
(Go). However, in this case the type it is trying to translate is a blank string (hence the unhelpful message).
Try replacing the problematic line with something that can be seen in the output like:
// panic(fmt.Sprintf("'%s'", s))
return "!HERE!"
Hopefully, if this is the only issue you will be able to see !HERE!
in the output Go and from there you will be able to see what data type it was trying to translate in the first place.
from c2go.
After changing that line you can simply run ./run-tests.sh
again. It will handle the compilation.
The !HERE!
token will cause the Go to fail to compile, that's OK. You want to see the output of build/main.go
(that will be the most recently generated go from the tests) and also have a look at /tmp/pp.c
- this is the preprocessed file that actually gets converted into Go.
from c2go.
@elliotchance Thanks for the quick answer! After modifying resolve.go
, rebuilding etc, go test seems to return ok but it doesn't generate the build/main.go
file. run-tests.sh
does, this is the output:
[...]
type _IO_FILE_plus struct {
}
type __io_read_fn interface{}
type line !HERE!
type __io_seek_fn interface{}
type __io_close_fn interface{}
type off_t __off_t
type ssize_t __ssize_t
func main() {
var number int
fmt.Printf("Enter an integer\n")
fmt.Scanf("%d", &number)
fmt.Printf("Integer entered by you is %d\n", number)
return
}
from c2go.
If you are seeing that Go output then you did not hit the error on that particular file, try running ./run-tests.sh
again.
Also, run-tests.sh
does all the preparation and compilation for you, no need for any other commands :)
from c2go.
I have traced the issue back to this line: 0x55b9da8784b0 <line:341:1, line:342:16> line:341:19 __io_write_fn '__ssize_t (void *, const char *, size_t)
Calling Parse on this line produces:
&main.TypedefDecl{Address:"0x55b9da8784b0", Position:"line:341:1, line:342:16", Position2:"", Name:"line", Type:"", Type2:"", IsImplicit:false, IsReferenced:false, Childre
n:[]interface {}{}}
from c2go.
I believe the problem is in parseTypedefDecl
the regex is looking for col:
after the >
however in this case the position is a line.
from c2go.
@bongo227 yes, that definitely looks like the issue. Can you please submit a PR for that change? With a test case
from c2go.
@bongo227 please try again with v0.8.4 and see if that fixes the issue.
from c2go.
Done. All tests parse.
from c2go.
Awesome. @carstenhag can you confirm this is now working for you? If so, close this issue.
from c2go.
go test
runs fine now, thanks!
Just a note, seems to take ~14sec now instead of the previous 6-7.
from c2go.
I have noticed the slow down with tests (well thats not really true, because it used to take the same amount of time with run-tests.sh
) and especially what all the new tests in #30 .
I have created a ticket to address this #47.
from c2go.
Related Issues (20)
- panic: unknown node type: 'MSAllocatorAttr 0x21a234729f0 <line:420:25>' HOT 1
- How to handle dependencies? HOT 2
- panic: could not match regexp with string HOT 1
- panic: unknown node type: 'CallbackAttr 0x562b0bc30c88 <line:199:12> Implicit 2 3'
- Cannot tranpile (sic)
- panic: unknown node type: ColdAttr HOT 1
- __int128 is translated as int64
- panic: unknown node type: BuiltinAttr HOT 2
- panic: unknown node type: 'BuiltinAttr 0x7fb08f04f838 <<invalid sloc>> Inherited Implicit 720' HOT 2
- panic: could not match regexp with string (translation_unit_decl) HOT 2
- 'const' removed from struct name / cannot determine sizeof union HOT 2
- docker container for c2go HOT 8
- panic: runtime error: invalid memory address or nil pointer dereference
- An alternative to github.com/elliotchance/c2go HOT 1
- panic: unknown node type: 'BuiltinAttr 0x10db7b0 <<invalid sloc>> Inherited Implicit 749' HOT 1
- FreeBSD implementation
- panic: unknown node type: 'BuiltinAttr 0x1d448112da0 <<invalid sloc>> Implicit 836' HOT 3
- Installation of c2go HOT 3
- Is it possible to convert .cpp aswell? HOT 1
- Compile `pikchr` source code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c2go.