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

Multifiles C code to single Go code #362

Closed
Konstantin8105 opened this issue Nov 23, 2017 · 1 comment
Closed

Multifiles C code to single Go code #362

Konstantin8105 opened this issue Nov 23, 2017 · 1 comment

Comments

@Konstantin8105
Copy link
Contributor

Konstantin8105 commented Nov 23, 2017

Now, we have the problem in multifile transpilation is separating #define on each file.
Solution
Example : c2go transpile 1.c 2.c 3.c ....

  1. Find all definition for 1.c like that:
clang -dM -E  1.c

Output:

#define BUFSIZ _IO_BUFSIZ
#define EOF (-1)
#define FILENAME_MAX 4096
#define FOPEN_MAX 16
#define L_ctermid 9
#define L_tmpnam 20
#define NULL ((void*)0)
...
  1. Transfer definition to file 2.c. Used -D of clang.
  2. ...
    Link for help: https://clang.llvm.org/docs/ClangCommandLineReference.html#dumping-preprocessor-state

Main task for issue: Transling sqlite files shell.c and sqlite3.c in one.

Last trying: https://github.com/Konstantin8105/c2go/blob/e70dfa5765eff7e05fdefaa754bf5c62b4a3986b/travis/test.sh

@elliotchance
Copy link
Owner

There is only two ways to transpile multiple files correctly:

  1. Merge all of the C files into a single C file to preprocess and transpile, resulting in one large Go file. (This is what we do as of v0.17.0).
  2. Transpile each C file completely independently (they do not affect each other at all) generating one Go file for each input C file. Then we remove the duplicated after the Go is produced. This is where we hope to get to. See Unused types, constants, vars #232 (comment).

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