Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling multiple files #63

Closed
elliotchance opened this issue Apr 23, 2017 · 3 comments
Closed

Compiling multiple files #63

elliotchance opened this issue Apr 23, 2017 · 3 comments

Comments

@elliotchance
Copy link
Owner

At the moment all the preprocessed code is output into a single Go file. If there were multiple files process you would get lots of duplicate symbols in the same package.

@elliotchance elliotchance added this to the Future Release milestone Apr 23, 2017
@cristim
Copy link

cristim commented Apr 26, 2017

Would it work if it transpiled the C source files one to one to corresponding Go files which would then be compiled together?

It should also somehow handle subdirectories, like creating them in golang as sub-packages.

@elliotchance
Copy link
Owner Author

There are some complexities to consider:

  1. Since the file (or files) are preprocessed in clang already theres no way of know which symbols belonged to which original file.
  2. We will run into Go problems with effectively all functions not being exported so having multiple packages and have them work together like they would in C might get really tricky.

I don't know if there is any easy answers for this yet, but I'm happy to take it one step at a time and change stuff if ways don't work.

@elliotchance
Copy link
Owner Author

One solution is to preprocess all input files together and output a single Go file. The advantage is its simple, easy and should word. The disadvantage is that you will end up with one truely enormous Go file for a decent sized library that will be difficult to maintain. It will also not be possible to combine multiple translations together because all the duplicate symbols.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants