Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
250 views
in Technique[技术] by (71.8m points)

pointers - How do I send array values ?to javascript->c using emscripten?

I am trying to send an arraybuffer of javascript to c using emscripten

Here my c code

#include <stdio.h>

void testFunc(uint8_t* data, int size)
{
    int i = 0;

    printf("data: %d
", data[i]);
}

and I made test.js using emcc

Here my Javascript code

<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <script type="text/javascript" src="test.js"></script>
        <script>
            window.onload = function() {
                setTimeout(() => {
                    const testcase = Module.cwrap('testFunc', null, ['number', 'number']);
                    console.log(testcase(???));
                }, 2000);
            }
        </script>
    </body>
</html>

I don't know what parameters are going to be in the cwrap function here

Thank you for your help

question from:https://stackoverflow.com/questions/65559519/how-do-i-send-array-values-to-javascript-c-using-emscripten

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...