最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error: Can't access lexical declaration - Stack Overflow

programmeradmin3浏览0评论
let textBytes = ctypes.uint8_t("hello"); 
let a = new SECItem;
a.type = siBuffer;
a.data = textBytes.address();
a.len = textBytes.length;

I got ReferenceError: can't access lexical declaration textBytes before initialization.

let textBytes = ctypes.uint8_t("hello"); 
let a = new SECItem;
a.type = siBuffer;
a.data = textBytes.address();
a.len = textBytes.length;

I got ReferenceError: can't access lexical declaration textBytes before initialization.

Share Improve this question edited Jun 27, 2015 at 9:18 Noitidart 37.4k40 gold badges179 silver badges359 bronze badges asked Jun 26, 2015 at 8:41 Nona HaronNona Haron 1711 gold badge1 silver badge6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 0

I can't reproduce the reference error you are getting, but I think change

let textBytes = ctypes.uint8_t("hello"); 

as this throws TypeError: expected type uint8_t, got "hello" to

let textBytes = ctypes.uint8_t.array()("hello"); 

This will give you a null-terminated string, of length 6. If you want it to be length 5, no null termination then do let textBytes = ctypes.uint8_t.array(5)("hello");

as I am thinking, change

let a = new SECItem;

to

let a = SECItem();

or let a = new SECItem(); they are both same.

If that doesn't fix it, please share the structure of SECItem and what is siBuffer.

发布评论

评论列表(0)

  1. 暂无评论