#include <string.h>
#include "./quickjs.h"
void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len,
int flags);
const uint8_t qjsc_hello[62] = {
0x02, 0x03, 0x0e, 0x63, 0x6f, 0x6e, 0x73, 0x6f,
0x6c, 0x65, 0x06, 0x6c, 0x6f, 0x67, 0x10, 0x68,
0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x6a, 0x73, 0x0e,
0x00, 0x06, 0x00, 0xa0, 0x01, 0x00, 0x01, 0x00,
0x03, 0x00, 0x00, 0x10, 0x01, 0xa2, 0x01, 0x00,
0x00, 0x00, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x42,
0xe1, 0x00, 0x00, 0x00, 0xb7, 0x24, 0x01, 0x00,
0xce, 0x28, 0xc4, 0x03, 0x01, 0x00,
};
const uint32_t qjsc_hello_size = 62;
const char* eval(const char* str) {
JSRuntime* runtime = JS_NewRuntime();
JSContext* ctx = JS_NewContext(runtime);
js_std_eval_binary(ctx, qjsc_hello, qjsc_hello_size, 0);
JS_FreeValue(ctx, result);
}
大佬你好,请教下大佬有没有编译过使用js_std_eval_binary的c。
mac系统,quickjs写的c里使用了js_std_eval_binary这个函数:
用emcc编译为js:
emcc -o eval.html eval.c ./quickjs-libc.c ./quickjs.c ./cutils.c ./libregexp.c ./libbf.c ./libunicode.c -D CONFIG_VERSION="\"1.0.0\"" -lm -s EXPORTED_FUNCTIONS='["_eval"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'报错error: use of undeclared identifier 'sighandler_t'
搜了挺多都没找到原因...求指教