Nodejs中带有uint8_t变量的C结构

标签 c node.js

我在用 C 语言编写的 Node.js 中创建结构时遇到问题,如下所示:

struct {
    uint8_t x;
    uint8_t *y;
    uint8_t z[16];
};

我尝试使用 ref、ref-struct、ffi 库,但没有成功。

谢谢!

最佳答案

const ArrayType = require('ref-array');
const StructType = require('ref-struct');

exports.StructName = StructType({
    x: 'uint8'
    y: ref.refType('uint8'),
    z: ArrayType('uint8', 16)
})

关于Nodejs中带有uint8_t变量的C结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22112093/

相关文章:

mysql - NodeJS 和 MYSQL - ER_ACCES_DENIED_ERROR : Acces denied for '' @'localhost' (using password: NO)

javascript - grunt.js 的全局安装失败

c - ssl_read(ssl, buffer, sizeof(buffer)) 没有正确读取json返回

node.js - Visual Studio/多设备混合应用程序 CTP/Cordova - 找不到导入的项目

javascript - Node JS pm2最大内存限制

c++ - C/C++ 旋转 BMP 图像

javascript - MongoDB 元素顺序

c - 从 C 中的字节数组中一次读取两个字节

收集2.exe : error: ld returned 1 exit status in eclipse cdt

c - 学习C、段错误