Error: Unable to access lexical declaration

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 the lexical declaration of textBytes before initialization.

+5


source to share


1 answer


I cannot reproduce the link error you are getting, but I think I will change

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

      

as it casts TypeError: expected type uint8_t, got "hello"

on

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, without zero sequence termination, do let textBytes = ctypes.uint8_t.array(5)("hello");

as i think change



let a = new SECItem;

      

to

let a = SECItem();

      

or let a = new SECItem();

they are both the same.

If this doesn't fix it, separate the structure SECItem

and what siBuffer

.

0


source







All Articles