Konstantin8105 / c4go

Transpiling C code to Go code
MIT License
363 stars 37 forks source link

stb_vorbis.c does not transpile #353

Closed electricface closed 5 years ago

electricface commented 5 years ago

https://github.com/nothings/stb/blob/master/stb_vorbis.c

c4go transpile stb_vorbis.c
panic: unknown operator: __extension__

goroutine 1 [running]:
github.com/Konstantin8105/c4go/transpiler.getTokenForOperator(0xc000e4c6e7, 0xd, 0xc0019a79e0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/operators.go:464 +0xa9a
github.com/Konstantin8105/c4go/transpiler.transpileUnaryOperator(0xc0017285a0, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/unary.go:523 +0xd7
github.com/Konstantin8105/c4go/transpiler.transpileToExpr(0x73a220, 0xc0017285a0, 0xc00010a000, 0x73a201, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:205 +0xd51
github.com/Konstantin8105/c4go/transpiler.transpileToStmt(0x73a220, 0xc0017285a0, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:420 +0x257
github.com/Konstantin8105/c4go/transpiler.transpileToStmts(0x73a220, 0xc0017285a0, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:297 +0xe3
github.com/Konstantin8105/c4go/transpiler.transpileBinaryOperatorComma(0xc0017281e0, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/binary.go:38 +0x162
github.com/Konstantin8105/c4go/transpiler.transpileToStmt(0x7389a0, 0xc0017281e0, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:385 +0xa00
github.com/Konstantin8105/c4go/transpiler.transpileToStmts(0x7389a0, 0xc0017281e0, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:297 +0xe3
github.com/Konstantin8105/c4go/transpiler.transpileCompoundStmt(0xc00056f570, 0xc00010a000, 0xc00010a000, 0x738e60, 0xc00056f570, 0xc0019a80e8, 0x6edea8, 0xc0001558b0, 0xc0019a8040, 0xc000000180, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/scope.go:66 +0x613
github.com/Konstantin8105/c4go/transpiler.transpileToStmt(0x738e60, 0xc00056f570, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:380 +0xab1
github.com/Konstantin8105/c4go/transpiler.transpileToStmts(0x738e60, 0xc00056f570, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:297 +0xe3
github.com/Konstantin8105/c4go/transpiler.transpileToBlockStmt(0x738e60, 0xc00056f570, 0xc00010a000, 0x739600, 0xc0006e3f80, 0x0, 0x0, 0x7376a0, 0xc00052d2f0, 0x0, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/scope.go:93 +0x49
github.com/Konstantin8105/c4go/transpiler.transpileIfStmt(0xc0006e3f80, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/branch.go:95 +0x981
github.com/Konstantin8105/c4go/transpiler.transpileToStmt(0x739620, 0xc0006e3f80, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:370 +0xdee
github.com/Konstantin8105/c4go/transpiler.transpileToStmts(0x739620, 0xc0006e3f80, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:297 +0xe3
github.com/Konstantin8105/c4go/transpiler.transpileCompoundStmt(0xc00056f340, 0xc00010a000, 0xc00010a000, 0x738e60, 0xc00056f340, 0xc0019a8780, 0x9, 0x0, 0x0, 0xc000000180, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/scope.go:66 +0x613
github.com/Konstantin8105/c4go/transpiler.transpileToStmt(0x738e60, 0xc00056f340, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:380 +0xab1
github.com/Konstantin8105/c4go/transpiler.transpileToStmts(0x738e60, 0xc00056f340, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:297 +0xe3
github.com/Konstantin8105/c4go/transpiler.transpileToBlockStmt(0x738e60, 0xc00056f340, 0xc00010a000, 0xc000d9ca20, 0x1, 0xc0017c0730, 0x0, 0x1, 0x0, 0x0, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/scope.go:93 +0x49
github.com/Konstantin8105/c4go/transpiler.transpileFunctionDecl(0xc000199790, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/functions.go:116 +0x25c6
github.com/Konstantin8105/c4go/transpiler.transpileToNode(0x7394a0, 0xc000199790, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:597 +0x679
github.com/Konstantin8105/c4go/transpiler.transpileTranslationUnitDecl(0xc00010a000, 0xc000130060, 0xc0019a9858, 0x73a0a0, 0xc000130060, 0xc00010a000, 0x4d3ea8)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/translation_unit.go:40 +0x1ee
github.com/Konstantin8105/c4go/transpiler.transpileToNode(0x73a0a0, 0xc000130060, 0xc00010a000, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:482 +0xcfb
github.com/Konstantin8105/c4go/transpiler.TranspileAST(0x0, 0x0, 0x6d542e, 0x4, 0xc000130000, 0xc00010a000, 0x73a0a0, 0xc000130060, 0xc000170000, 0x3ab, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/transpiler/transpiler.go:102 +0x221
main.generateGoCode(0x0, 0xc0000101a0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6d542e, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/main.go:469 +0x6d3
main.Start(0x0, 0xc0000101a0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6d542e, ...)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/main.go:337 +0x217
main.runCommand(0x0)
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/main.go:639 +0x8ea
main.main()
    /home/tp/program_lang/go/src/github.com/Konstantin8105/c4go/main.go:510 +0x22
Konstantin8105 commented 5 years ago

Dear @electricface, do you want research that problem and create PR?

electricface commented 5 years ago

no

Konstantin8105 commented 5 years ago

Thank you for clarification and issue. I will look later.

Konstantin8105 commented 5 years ago

add script for that C library, you can run ./scripts/vorbis.sh and look in folder ./testdata/vorbis

electricface commented 5 years ago

But there are still many errors and warnings

Konstantin8105 commented 5 years ago

Now, little bit less warnings:

Calculate warnings in file: testdata/vorbis/vorbis.go
        After transpiling : 4 warnings.
        Go build : 25 warnings
        Unsafe : 255

Please clarify - is it still important for you?

electricface commented 5 years ago

unimportant

Konstantin8105 commented 5 years ago

Now, that project is haven't some specific problem.

Calculate warnings in file: testdata/vorbis/vorbis.go
                After transpiling : 0 warnings.
                Go build : 3 warnings
                Unsafe   : 257

Thank for issue. Closed.