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 variable: codegen regression #12081

Open
mratsim opened this issue Aug 28, 2019 · 1 comment
Open

Exportc variable: codegen regression #12081

mratsim opened this issue Aug 28, 2019 · 1 comment

Comments

@mratsim
Copy link
Collaborator

mratsim commented Aug 28, 2019

My workaround for #9365 relied on stable Nim->C symbols and needed to be updated after #11985.

I would use {.exportc.} in the affected place to ensure Nim->C symbol mapping.

Unfortunately, {.exportc.} variables are not properly generated anymore after #11985

Test case:

template foo(): untyped =
  let ompsize{.exportc.} = 123
  echo ompsize

proc main() =
  foo()

main()
/home/beta/.cache/nim/expc_d/expc.nim.c:103:12: error: stray ‘`’ in program
  103 |  NI ompsize`gensym178008;
      |            ^
/home/beta/.cache/nim/expc_d/expc.nim.c:103:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym178008’
  103 |  NI ompsize`gensym178008;
      |             ^~~~~~~~~~~~
/home/beta/.cache/nim/expc_d/expc.nim.c:103:13: error: ‘gensym178008’ undeclared (first use in this function)
/home/beta/.cache/nim/expc_d/expc.nim.c:103:13: note: each undeclared identifier is reported only once for each function it appears in
/home/beta/.cache/nim/expc_d/expc.nim.c:107:9: error: stray ‘`’ in program
  107 |  ompsize`gensym178008 = ((NI) 123);
      |         ^
/home/beta/.cache/nim/expc_d/expc.nim.c:107:2: error: unknown type name ‘ompsize’
  107 |  ompsize`gensym178008 = ((NI) 123);
      |  ^~~~~~~
/home/beta/.cache/nim/expc_d/expc.nim.c:111:30: error: stray ‘`’ in program
  111 |  T1_[0] = nimIntToStr(ompsize`gensym178008);
      |                              ^
/home/beta/.cache/nim/expc_d/expc.nim.c:111:23: error: ‘ompsize’ undeclared (first use in this function)
  111 |  T1_[0] = nimIntToStr(ompsize`gensym178008);
      |                       ^~~~~~~
/home/beta/.cache/nim/expc_d/expc.nim.c:111:30: error: expected ‘)’ before ‘gensym178008’
  111 |  T1_[0] = nimIntToStr(ompsize`gensym178008);
      |                              ^~~~~~~~~~~~~
      |                              )
@mratsim
Copy link
Collaborator Author

mratsim commented Aug 28, 2019

Tagging low-priority as there is an easy workaround by specifying the name explicitly

template foo(): untyped =
  let ompsize{.exportc: "ompsize".} = 123
  echo ompsize

proc main() =
  foo()

main(

@metagn metagn added the FFI label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants