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 procedures in other procedures can get deleted #20974

Open
Menduist opened this issue Nov 29, 2022 · 0 comments
Open

exportc procedures in other procedures can get deleted #20974

Menduist opened this issue Nov 29, 2022 · 0 comments
Labels

Comments

@Menduist
Copy link
Contributor

Menduist commented Nov 29, 2022

Description

proc heya* =
  proc zzz {.exportc.} =
    echo "yey"
    
heya()
proc zzz {.importc.}
zzz()

Nim Version

d73fff1

Current Output

@mtestb.nim.c:(.text+0x230): undefined reference to `zzz'

Expected Output

Compiles

Possible Solution

My use case is that zzz is generated by a macro, but not a closure, so it can be called from C safely.
Cannot add * to prevent deletion by the compiler as this is not a top level procedure

Workaround:

proc heya* =
  proc zzz {.exportc.} =
    echo "yey"
  if false: zzz()
    
heya()
proc zzz {.importc.}
zzz()

Additional Information

No response

@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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants