elliotchance / c2go

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

How to handle dependencies? #874

Closed ivanjaros closed 3 years ago

ivanjaros commented 3 years ago

I know c2go handles one file at a time but that is almost never the case and files have imports. So what is a good/proper way to transpile all the necessary files properly? I am no C guy so my knowledge is basic but would it be possible to manually, since c2go does not support traversing of imports, concat the necessary files into one big .c file and run c2go on it or would that just made my computer explode out of sheer desperation of what i am doing to it :D ?

elliotchance commented 3 years ago

c2go doesn't actually handle the C code or file names directly, so it doesn't handle one file at a time in that way. It passes the C file path given through clang for preprocessing. The preprocessing generates a possibly much larger file with all the includes, macros, etc which is then parsed with clang and c2go reads the AST from the clang output.

You could create a file that includes all the files you wish to transpile (make sure itself compiles) and try passing that into c2go.

ivanjaros commented 3 years ago

ah, ok. thanks. i was toying with ffmpeg but i doubt i will make it work. still, this project is awesome!