Nim icon indicating copy to clipboard operation
Nim copied to clipboard

Exportc variable: codegen regression

Open mratsim opened this issue 6 years ago • 1 comments
trafficstars

My workaround for https://github.com/nim-lang/Nim/issues/9365 relied on stable Nim->C symbols and needed to be updated after https://github.com/nim-lang/Nim/pull/11985.

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

Unfortunately, {.exportc.} variables are not properly generated anymore after https://github.com/nim-lang/Nim/pull/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 avatar Aug 28 '19 18:08 mratsim