output byref types into --header file [backport: 1.6] (#19505)

* output byref types into --header file

fix #19445

* fix comments

* set targets
This commit is contained in:
flywind
2022-03-24 03:57:13 +08:00
committed by GitHub
parent b0bd4320a0
commit 2c01c9c4c8
3 changed files with 23 additions and 2 deletions

View File

@@ -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", [])

3
tests/ccgbugs/m19445.c Normal file
View File

@@ -0,0 +1,3 @@
#include "m19445.h"
const Foo f = {10, 20, 30, 40};

13
tests/ccgbugs/t19445.nim Normal file
View File

@@ -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".}