Skip to content

Commit

Permalink
output byref types into --header file [backport: 1.6] (nim-lang#19505)
Browse files Browse the repository at this point in the history
* output byref types into --header file

fix nim-lang#19445

* fix comments

* set targets
  • Loading branch information
ringabout authored and PMunch committed Mar 28, 2022
1 parent ee034ea commit 37ce926
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
9 changes: 7 additions & 2 deletions compiler/ccgtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,13 @@ proc genProcParams(m: BModule, t: PType, rettype, params: var Rope,
var arr = t[0]
if params != nil: params.add(", ")
if mapReturnType(m.config, t[0]) != ctArray:
params.add(getTypeDescWeak(m, arr, check, skResult))
params.add("*")
if isHeaderFile in m.flags:
# still generates types for `--header`
params.add(getTypeDescAux(m, arr, check, skResult))
params.add("*")
else:
params.add(getTypeDescWeak(m, arr, check, skResult))
params.add("*")
else:
params.add(getTypeDescAux(m, arr, check, skResult))
params.addf(" Result", [])
Expand Down
3 changes: 3 additions & 0 deletions tests/ccgbugs/m19445.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "m19445.h"

const Foo f = {10, 20, 30, 40};
13 changes: 13 additions & 0 deletions tests/ccgbugs/t19445.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
discard """
matrix: "--nimcache:tests/ccgbugs/nimcache19445 --cincludes:nimcache19445 --header:m19445"
targets: "c"
"""

# bug #19445
type
Foo* {.exportc.} = object
a*, b*, c*, d*: int

proc dummy(): Foo {.exportc.} = discard

{.compile:"m19445.c".}

0 comments on commit 37ce926

Please sign in to comment.