私はここに完全な例を置いて、これが正しい方法であるかどうかわかりません! comple:Emscriptenとjqueryクリックコールバック、問題?
emcc jquery001.cpp -o jquery001.js -s EXPORTED_FUNCTIONS="['_x_click','_webmain']"
すべてが常に最後のprintfないだけでなく、ほかのプログラムの仕事ですが... printf関数 ショーと思われますが
初期出力前:
pre-main prep time: 11 ms
jquery001.js:143
jquery001.js:143 enter webmain
jquery001.js:143 webmain <>
終了ウェブをmainはmissigです:printf( "\ n exit webmain");
その要素の例に 'クリック' と表示されます。
exit webmain
jquery001.js:143 enter x_click
jquery001.js:143 x_click event <x1>
をprintfのメイン...ではなくprintfの出口ウェブ( "\ nの出口x_click");
何が問題なのですか。時点でその文字列が改行に達するまでprintf
に渡される引数をバッファリングして出力するとともに
[jquery001.html]
<!DOCTYPE html>
<html>
<head>
<title>emcc & jquery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<label id="x1" class="x" >emscripten1</label>
<label id="x2" class="x" >emscripten2</label>
</body>
<script src="jquery001.js"></script>
<script>
Module.ccall('webmain', 'number', ['string'],['']);
</script>
</html>
[jquery001.cpp]
#include <stdio.h>
#include <stdlib.h>
#include <emscripten.h>
#include <string.h>
#include <string>
extern "C"
{
int x_click( char *s)
{
printf ("\n enter x_click");
printf ("\n x_click event <%s>",s);
printf ("\n exit x_click");
return 0 ;
}
int webmain(char *s)
{
printf ("\n enter webmain");
printf ("\n webmain <%s>",s);
int x = EM_ASM_INT({
$('.x').click(function(e)
{
Module.ccall('x_click', 'number', ['string'],[e.target.id]);
});
return 0;
}, NULL);
printf ("\n exit webmain");
return 0 ;
}
}
int main (void)
{
return 0 ;
}
あなたが示すよう完璧に動作私に(私が評判の15に達すると+1)! –