Próbuję zbudować rozszerzenie przeglądarki Firefox, które musi wywoływać natywny kod C.Jak wywołać natywny kod C, używając rozszerzenia js-ctypes Firefox?
Mój kod programu C:
#include<windows.h>
int add(int a, int b)
{
return(a + b);
}
i mój kod JavaScript jest:
var {Cu} = require('chrome');
var self = require('sdk/self');
Cu.import("resource://gre/modules/ctypes.jsm");
var lib;
var puts;
lib = ctypes.open('G:\\Shankar\\Project\\Maidsafe\\Firefox\\addon-sdk-1.17\\jsctype_sample\\data\\Win32Project1.dll');
try {
puts = lib.declare("add", /* function name */
ctypes.default_abi, /* call ABI */
ctypes.int32_t, /* return type */
ctypes.int32_t, /* argument type */
ctypes.int32_t /* argument type */
);
} catch (e) {
console.log('Érror'+ e);
}
function binaryFile() {
var ret = puts(1, 2);
dump(ret);
lib.close();
};
exports.binaryFile = binaryFile;
podczas wywoływania funkcji binaryFile
, pojawia się błąd
Couldn't find function symbol in library
Proszę mi pomóc na zewnątrz. tHanks z góry.
Nie powinieneś używać 'int' zamiast' int32_t'? – meskobalazs