-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 now mangles same as importc, fixes #10578 #12144
Conversation
This is a breaking change. It needs a changelog entry and it requires us to introduce |
done.
notesee timotheecour@fd86320 for an alternative to producing an error: if c.config.cmd == cmdCompileToC:
let m = s.getModule()
incl(m.flags, sfCompileToCpp)
incl c.config.globalOptions, optMixedMode and adjust proc fun1() {.exportc.} = discard # in cgen, will be processed as if sfCompileToCpp notin m
proc funx1() {.exportcpp.} = discard # triggers sfCompileToCpp in m
proc fun1() {.exportc.} = discard # in cgen, will be processed with sfCompileToCpp in m not sure why cgen doesn't come after semantic is completed, but that can be investigated later to enable that niche use case |
317bbaf
to
2be8692
Compare
Thank you! |
This is awesome! Does it mean that I do not need to scatter my Nim wrappers with this? const
externCDecl* = when defined(cpp):
"""extern "C" $1 $2 $3"""
else:
"""$1 $2 $3"""
# ..
proc foo() {.exportc, codegenDecl: externCDecl.} =
# .. i.e. Below will now result in unmangled proc symbols whether I do proc foo() {.exportc.} =
# .. |
indeed (let me know if that's not the case somehow), except if you need to support nim versions prior to this PR |
exportc
mangles as C++ and doesn't work withimportc
(C) withnim cpp
#10578[EDIT] note
{.emit: "NIM_EXTERNC".}
is harmless so it's ok to have: