mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-04 19:04:46 +00:00
fixes #12703; nim cpp rejects valid code would lose const qualifier for cstring to string via cstrToNimstr (#23371)
fixes #12703 ref #19588
This commit is contained in:
@@ -59,3 +59,17 @@ block: # bug #10219
|
||||
|
||||
var v1 = initVector[int](10)
|
||||
doAssert v1[0] == 0
|
||||
|
||||
block: # bug #12703 bug #19588
|
||||
type
|
||||
cstringConstImpl {.importc:"const char*".} = cstring
|
||||
constChar = distinct cstringConstImpl
|
||||
|
||||
{.emit: """
|
||||
const char* foo() {
|
||||
return "hello";
|
||||
}
|
||||
""".}
|
||||
proc foo(): constChar {.importcpp.} # change to importcpp for C++ backend
|
||||
doAssert $(foo().cstring) == "hello"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user