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

importc not generated for typedef #242

Open
arnetheduck opened this issue Jun 13, 2022 · 0 comments
Open

importc not generated for typedef #242

arnetheduck opened this issue Jun 13, 2022 · 0 comments

Comments

@arnetheduck
Copy link

typedef void (*some_proc)(const void *key);

void xxx(some_proc p);
type
  SomeProc* = proc (key: pointer) {.cdecl.}

proc xxx*(p: SomeProc) {.cdecl, importc: "xxx", header: "test.h".}

importc here is needed to ensure that the C typedef is used where relevant, and not the thing that Nim thinks is equivalent: Nim lacks the language to represent const void* correctly - this leads to compile issues down the line with const-vs-non-const type problems.

The above should be SomeProc* {.importc: "some_proc", header: "test.h".} = proc (key: pointer) {.cdecl.}

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

1 participant