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

invalid code generated for extern const #241

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

invalid code generated for extern const #241

arnetheduck opened this issue Jun 13, 2022 · 2 comments

Comments

@arnetheduck
Copy link

Header:

extern const int xxx_symbol;

Command:

$ c2nim --version
0.9.18

$ c2nim --header --importc --nep1 test.h

Output:

let xxxSymbol* {.header: "test.h".}: cint

several problems with the generated definition:

  • it's missing importc: "xxx_symbol"
  • it should be a var (because let needs an initializer which in this case is not provided in nim (it's done in the C library typically)

Of course, the main issue here is that Nim has no feature that expresses the concept of an extern const in general, so var is the closest that we can get.

@Araq
Copy link
Member

Araq commented Jun 15, 2022

let x {.importc.} <init missing> is Nim's notion of "extern const". IIRC this was added for this reason.

@arnetheduck
Copy link
Author

is Nim's notion of "extern const"

right, I was testing this with nim 1.2 where it's not allowed - it's also still missing the actual importc

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