When running translate-c I get 344:40: expected ')' on this code c printf("QuickJS Compiler version " CONFIG_VERSION "\n" "usage: " PROG_NAME " [options] [files]\n" "\n" "options are:\n" "-c only output bytecode in a C file\n" "-e output main() and bytecode in a C file (default = executable output)\n" "-o output set the output filename\n" "-N cname set the C name of the generated data\n" "-m compile as Javascript module (default=autodetect)\n" "-D module_name compile a dynamically loaded module or worker\n" "-M module_name[,cname] add initialization code for an external C module\n" "-x byte swapped output\n" "-p prefix set the prefix of the generated C names\n" "-S n set the maximum stack size to 'n' bytes (default=%d)\n", JS_DEFAULT_STACK_SIZE);. I also get :457:9: use of undeclared identifier 'load_jscalc' where c #ifdef CONFIG_BIGNUM int load_jscalc; #endif. Guessing I might need some way for translate-c to know env vars?
#translate-c chokes on printf env vars and vars declared in IFDEF
1 messages · Page 1 of 1 (latest)
-DCONFIG_BIGNUM -DCONFIG_VERSION=1.2.3 etc should work
On the command line to translate-c
Trying to convert the entirety of qjs to zig is unlikely to work though
Generally you'd just convert the headers and link to the C code
with Cimport and linkLibC?
Yep, @cImport in your zig code, linkLibC and addCSourceFiles in your build.zig
fwiw zig translate-c -DCONFIG_VERSION=2021-03-27 qjsc.c > qjsc.zig isn't changing my. output
You may be missing some other config variables
check qjs's build system
translate-c generally needs all the same flags you'd pass to the C compiler
is there a way for translate-c to get access to the Makefile?
Looking at ~500 lines of config
No, you have to translate that
You could perhaps try some hack like CC='zig translate-c' but it'd require a lot of prodding to work
ah, thinking i might go through this https://vimeo.com/521627209
https://ziglang.org/ If you like what we're doing and want to support more core team members to work full time on this, don't forget to set up a monthly…