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

Exportc with const name in templates: "undeclared identifier" #9366

Closed
mratsim opened this issue Oct 14, 2018 · 1 comment
Closed

Exportc with const name in templates: "undeclared identifier" #9366

mratsim opened this issue Oct 14, 2018 · 1 comment
Labels

Comments

@mratsim
Copy link
Collaborator

mratsim commented Oct 14, 2018

While trying to find a workaround to #9365, I find out that exportc doesn't find const variable in a template:

var i {.compileTime.} = 0

proc genSuffix(): static int =
  result = i
  inc i

template foo() = # Works if proc
  const
    suffix = genSuffix()
    ompsize_Csym = "ompsize_" & $suffix
  static:
    echo ompsize_Csym

  let ompsize {.exportc: ompsize_Csym.} = 100 # Fails
  # let ompsize = 100 # works
  # let ompsize {.exportc: "ompsize_" & $genSuffix().} = 100 # works
  echo ompsize

foo()
foo()
Error: undeclared identifier: 'ompsize_Csym'
@LemonBoy
Copy link
Contributor

The template renaming pass does not affect the content of the pragmas so ompsize_Csym is indeed undeclared where foo is instantiated.

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

No branches or pull requests

3 participants