Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to define a struct with a lot char array? #13

Open
AllenBird opened this issue Jul 30, 2020 · 2 comments
Open

How to define a struct with a lot char array? #13

AllenBird opened this issue Jul 30, 2020 · 2 comments

Comments

@AllenBird
Copy link

for example:

typedef struct tagIDCardData {
char Name[32];
char Sex[6];
char Nation[64];
char Born[18];
char Address[72];
char IDCardNo[38];
} IDCardData;

@maneetgoyal
Copy link

maneetgoyal commented Jun 7, 2021

May be this?

import refNAPI from "ref-napi";
import StructType from "ref-struct-di";
import ArrayType from "ref-array-di";

const NAPIStructType = StructType(refNAPI);
const NAPIArrayType = ArrayType(refNAPI);

export const IDCardData = NAPIStructType({
  Name: NAPIArrayType(refNAPI.types.char, 32),
  Sex: NAPIArrayType(refNAPI.types.char, 6),
  Nation: NAPIArrayType(refNAPI.types.char, 64),
  Born: NAPIArrayType(refNAPI.types.char, 18),
  Address: NAPIArrayType(refNAPI.types.char, 72),
  IDCardNo: NAPIArrayType(refNAPI.types.char, 38),
});

@maneetgoyal
Copy link

#17 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants