Giter VIP home page Giter VIP logo

Comments (12)

elliotchance avatar elliotchance commented on August 23, 2024

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.

elliotchance avatar elliotchance commented on August 23, 2024

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.

carstenhag avatar carstenhag commented on August 23, 2024

@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
}

Gist for pp.c

from c2go.

elliotchance avatar elliotchance commented on August 23, 2024

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.

zoeyfyi avatar zoeyfyi commented on August 23, 2024

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.

zoeyfyi avatar zoeyfyi commented on August 23, 2024

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.

elliotchance avatar elliotchance commented on August 23, 2024

@bongo227 yes, that definitely looks like the issue. Can you please submit a PR for that change? With a test case

from c2go.

elliotchance avatar elliotchance commented on August 23, 2024

@bongo227 please try again with v0.8.4 and see if that fixes the issue.

from c2go.

zoeyfyi avatar zoeyfyi commented on August 23, 2024

Done. All tests parse.

from c2go.

elliotchance avatar elliotchance commented on August 23, 2024

Awesome. @carstenhag can you confirm this is now working for you? If so, close this issue.

from c2go.

carstenhag avatar carstenhag commented on August 23, 2024

go test runs fine now, thanks!

Just a note, seems to take ~14sec now instead of the previous 6-7.

from c2go.

elliotchance avatar elliotchance commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.