Хорошо, поэтому я только начал использовать Emscripten и постоянно сталкивался с ошибками в Module.arguments. Аргументы никогда не go in или они выдают ошибку прерывания -1. Использование аргументов всякий раз, когда модуль определен, тоже не помогает. Я проверил https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html, который тоже не помог. Вот мой код JS для изменения аргументов:
<script type='text/javascript'>
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
var spinnerElement = document.getElementById('spinner');
var Module = {
arguments: [], <----Editing this will not influence program, gives -1 abort error
preRun: [],
postRun: [],
print: (function() {
Мой код C выглядит следующим образом:
static void parse_args(int argc, char *argv[]) {
int option_index;
int c;
static const char* short_options = "hl:c:u:e:d:b:g:a:p";
static struct option long_options[] = {
{ "help", ARG_NONE, ARG_NULL, 'h' },
//MORE OPTIONS
};
Я хочу использовать Module.arguments для влияния на управление программой в преобразованный C код. Я проверил этот пост https://softwareengineering.stackexchange.com/questions/325887/emscripten-passing-command-line-arguments/329626, и он не дал четкого ответа и все равно не решил мою проблему. Мое сообщение об ошибке таково:
Promise.then (async)
instantiateArrayBuffer @ main.js:1768
(anonymous) @ main.js:1787
Promise.then (async)
(anonymous) @ main.js:1782
Promise.then (async)
instantiateAsync @ main.js:1780
createWasm @ main.js:1807
(anonymous) @ main.js:2152
main.js:1636 Uncaught RuntimeError: abort(-1) at Error
at jsStackTrace (http://localhost:8080/main.js:1851:17)
at stackTrace (http://localhost:8080/main.js:1868:16)
at abort (http://localhost:8080/main.js:1630:44)
at _list_alloc (http://localhost:8080/main.js:2082:40)
at wasm-function[27]:0x5e7
at Module._main (http://localhost:8080/main.js:2165:32)
at callMain (http://localhost:8080/main.js:2462:15)
at doRun (http://localhost:8080/main.js:2524:23)
at http://localhost:8080/main.js:2535:7
at abort (http://localhost:8080/main.js:1636:9)
at _list_alloc (http://localhost:8080/main.js:2082:40)
at wasm-function[27]:0x5e7
at Module._main (http://localhost:8080/main.js:2165:32)
at callMain (http://localhost:8080/main.js:2462:15)
at doRun (http://localhost:8080/main.js:2524:23)
at http://localhost:8080/main.js:2535:7
abort @ main.js:1636
_list_alloc @ main.js:2082
(anonymous) @ 00041476-27:68
Module._main @ main.js:2165
callMain @ main.js:2462
doRun @ main.js:2524
(anonymous) @ main.js:2535
setTimeout (async)
run @ main.js:2531
Ожидаемый результат должен быть аргументом, передаваемым некоторое время l oop в parse_args, который выводит сообщение. Я хочу управлять выводом программы из Javascript в значение C.