fixes #5136
This commit is contained in:
parent
06a8d37f9a
commit
d2fe857f94
2 changed files with 16 additions and 6 deletions
|
|
@ -732,10 +732,12 @@ proc genProcNoForward(m: BModule, prc: PSym) =
|
||||||
# dependency to a compilerproc:
|
# dependency to a compilerproc:
|
||||||
discard cgsym(m, prc.name.s)
|
discard cgsym(m, prc.name.s)
|
||||||
return
|
return
|
||||||
if lfNoDecl in prc.loc.flags:
|
if sfImportc in prc.flags:
|
||||||
fillProcLoc(m, prc)
|
fillProcLoc(m, prc)
|
||||||
useHeader(m, prc)
|
if lfHeader in prc.loc.flags:
|
||||||
genProcPrototype(m, prc)
|
useHeader(m, prc)
|
||||||
|
elif lfNoDecl notin prc.loc.flags:
|
||||||
|
genProcPrototype(m, prc)
|
||||||
elif prc.typ.callConv == ccInline:
|
elif prc.typ.callConv == ccInline:
|
||||||
# We add inline procs to the calling module to enable C based inlining.
|
# We add inline procs to the calling module to enable C based inlining.
|
||||||
# This also means that a check with ``q.declaredThings`` is wrong, we need
|
# This also means that a check with ``q.declaredThings`` is wrong, we need
|
||||||
|
|
@ -760,15 +762,13 @@ proc genProcNoForward(m: BModule, prc: PSym) =
|
||||||
symInDynamicLib(q, prc)
|
symInDynamicLib(q, prc)
|
||||||
else:
|
else:
|
||||||
symInDynamicLibPartial(m, prc)
|
symInDynamicLibPartial(m, prc)
|
||||||
elif sfImportc notin prc.flags:
|
else:
|
||||||
var q = findPendingModule(m, prc)
|
var q = findPendingModule(m, prc)
|
||||||
fillProcLoc(q, prc)
|
fillProcLoc(q, prc)
|
||||||
useHeader(m, prc)
|
useHeader(m, prc)
|
||||||
genProcPrototype(m, prc)
|
genProcPrototype(m, prc)
|
||||||
if q != nil and not containsOrIncl(q.declaredThings, prc.id):
|
if q != nil and not containsOrIncl(q.declaredThings, prc.id):
|
||||||
genProcAux(q, prc)
|
genProcAux(q, prc)
|
||||||
else:
|
|
||||||
fillProcLoc(m, prc)
|
|
||||||
|
|
||||||
proc requestConstImpl(p: BProc, sym: PSym) =
|
proc requestConstImpl(p: BProc, sym: PSym) =
|
||||||
var m = p.module
|
var m = p.module
|
||||||
|
|
|
||||||
10
tests/cpp/tgen_prototype_for_importc.nim
Normal file
10
tests/cpp/tgen_prototype_for_importc.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
cmd: "nim cpp $file"
|
||||||
|
output: '''Hello world'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #5136
|
||||||
|
|
||||||
|
{.compile: "foo.c".}
|
||||||
|
proc myFunc(): cstring {.importc.}
|
||||||
|
echo myFunc()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue