elliotchance / c2go

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

printf() has a different syntax to Go #94

Open elliotchance opened 7 years ago

elliotchance commented 7 years ago

There are some symbols in C's printf, like %ld that are not supported in Go. It results in Go printing something like %!!(MISSING).

There should be a noarch.Printf(), but only used when the first argument cannot be determined to not include these syntax to improve performance when most of the time it is a string literal.

Konstantin8105 commented 6 years ago

Documantation: http://www.cplusplus.com/reference/cstdio/printf/

kamphaus commented 5 years ago

Maybe it's possible to transpile MUSL's printf implementation and use that as noarch.Printf?

Konstantin8105 commented 5 years ago

You can use that code as protitype. https://github.com/Konstantin8105/c4go/blob/bb2ab78fe0fb931f5fc42afee3501b7b02742148/transpiler/literals.go#L35-L52 And use like that: https://github.com/Konstantin8105/c4go/blob/bb2ab78fe0fb931f5fc42afee3501b7b02742148/transpiler/literals.go#L58