mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
@@ -243,7 +243,10 @@ proc genSingleVar(p: BProc, a: PNode) =
|
||||
if params != nil: params.add(~", ")
|
||||
assert(sonsLen(typ) == sonsLen(typ.n))
|
||||
add(params, genOtherArg(p, value, i, typ))
|
||||
lineF(p, cpsStmts, "$#($#);$n", [decl, params])
|
||||
if params == nil:
|
||||
lineF(p, cpsStmts, "$#;$n", [decl])
|
||||
else:
|
||||
lineF(p, cpsStmts, "$#($#);$n", [decl, params])
|
||||
else:
|
||||
initLocExprSingleUse(p, value, tmp)
|
||||
lineF(p, cpsStmts, "$# = $#;$n", [decl, tmp.rdLoc])
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
discard """
|
||||
targets: "cpp"
|
||||
output: '''6.0'''
|
||||
output: '''6.0
|
||||
0'''
|
||||
"""
|
||||
|
||||
# bug #4730
|
||||
@@ -20,3 +21,16 @@ proc main =
|
||||
echo v[0]
|
||||
|
||||
main()
|
||||
|
||||
#------------
|
||||
|
||||
#bug #6837
|
||||
type StdString {.importCpp: "std::string", header: "<string>", byref.} = object
|
||||
proc initString(): StdString {.constructor, importCpp: "std::string(@)", header: "<string>".}
|
||||
proc size(this: var StdString): csize {.importCpp: "size", header: "<string>".}
|
||||
|
||||
proc f(): csize =
|
||||
var myString: StdString = initString()
|
||||
return myString.size()
|
||||
|
||||
echo f()
|
||||
|
||||
Reference in New Issue
Block a user