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

[exceptions:goto] C compiler error with dynlib pragma calling a proc #14240

Closed
Yardanico opened this issue May 6, 2020 · 0 comments
Closed

Comments

@Yardanico
Copy link
Collaborator

Yardanico commented May 6, 2020

This code triggers an error in the C compiler due to nimErr not being declared in the file at all. Found in https://github.com/paranim/paravim.

Example

proc getLib(): string = "libvim.so"

proc vimWindowSetWidth*(width: cint) {.cdecl, dynlib: getLib(), importc.}
vimWindowSetWidth(cint 768)

Compiled C code output - https://gist.github.com/Yardanico/cf934690ba86bfa8a8949c3f94bd2653

Current Output

In file included from /home/dian/.cache/nim/libvim_r/@mlibvim.nim.c:11:
/home/dian/.cache/nim/libvim_r/@mlibvim.nim.c: In function 'libvimDatInit000':
/home/dian/.cache/nim/libvim_r/@mlibvim.nim.c:123:20: error: 'nimErr_' undeclared (first use in this function); did you mean 'nimfr_'?
  123 |  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
      |                    ^~~~~~~
/home/dian/.nim/lib/nimbase.h:519:44: note: in definition of macro 'NIM_UNLIKELY'
  519 | #  define NIM_UNLIKELY(x) __builtin_expect(x, 0)
      |                                            ^
/home/dian/.cache/nim/libvim_r/@mlibvim.nim.c:123:20: note: each undeclared identifier is reported only once for each function it appears in
  123 |  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
      |                    ^~~~~~~
/home/dian/.nim/lib/nimbase.h:519:44: note: in definition of macro 'NIM_UNLIKELY'
  519 | #  define NIM_UNLIKELY(x) __builtin_expect(x, 0)
      |                                            ^
/home/dian/.cache/nim/libvim_r/@mlibvim.nim.c:123:2: error: label 'BeforeRet_' used but not defined
  123 |  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
      |  ^~
Error: execution of an external compiler program 'gcc -c  -w -O3 -fno-strict-aliasing -fno-ident  -I/home/dian/.nim/lib -I/home/dian/Projects/data/paravim/src/paravim -o /home/dian/.cache/nim/libvim_r/@mlibvim.nim.c.o /home/dian/.cache/nim/libvim_r/@mlibvim.nim.c' failed with exit code: 1
$ nim -v
Nim Compiler Version 1.3.1 [Linux: amd64]
Compiled at 2020-05-05
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: e86a6d24d5ffe43e9dc7f230b80c274167376225
active boot switches: -d:release
@Yardanico Yardanico changed the title [ARC] C compiler error with dynlib pragma calling a proc [exceptions:goto] C compiler error with dynlib pragma calling a proc May 6, 2020
Araq added a commit that referenced this issue Jun 22, 2020
@Araq Araq closed this as completed in 451129d Jun 22, 2020
narimiran pushed a commit that referenced this issue Jun 24, 2020
(cherry picked from commit 451129d)
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