diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-11-16 17:22:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-16 10:22:51 +0100 |
commit | 06cd15663d6aed6cbf03a265f546043c47f250d4 (patch) | |
tree | 644bcc378c2a044655df58a91058b7c73e478d06 /lib/std/formatfloat.nim | |
parent | 3d692d08f74e41588fa157b006e882f142bd77d4 (diff) | |
download | Nim-06cd15663d6aed6cbf03a265f546043c47f250d4.tar.gz |
fixes ptr to cstring warnings[backport] (#20848)
* fix =#13790 ptr char (+friends) should not implicitly convert to cstring * Apply suggestions from code review * first round; compiles on windows * nimPreviewSlimSystem * conversion is unsafe, cast needed * fixes more tests * fixes asyncnet * another try another error * last one * true * one more * why bugs didn't show at once * add `nimPreviewCstringConversion` switch * typo * fixes ptr to cstring warnings[backport] * add fixes Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
Diffstat (limited to 'lib/std/formatfloat.nim')
-rw-r--r-- | lib/std/formatfloat.nim | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/formatfloat.nim b/lib/std/formatfloat.nim index 6f2383760..2850f7021 100644 --- a/lib/std/formatfloat.nim +++ b/lib/std/formatfloat.nim @@ -49,7 +49,7 @@ proc writeFloatToBufferSprintf*(buf: var array[65, char]; value: BiggestFloat): ## ## returns the amount of bytes written to `buf` not counting the ## terminating '\0' character. - var n: int = c_sprintf(addr buf, "%.16g", value) + var n: int = c_sprintf(cast[cstring](addr buf), "%.16g", value) var hasDot = false for i in 0..n-1: if buf[i] == ',': @@ -90,7 +90,7 @@ proc addFloatRoundtrip*(result: var string; x: float | float32) = else: var buffer {.noinit.}: array[65, char] let n = writeFloatToBufferRoundtrip(buffer, x) - result.addCstringN(cstring(buffer[0].addr), n) + result.addCstringN(cast[cstring](buffer[0].addr), n) proc addFloatSprintf*(result: var string; x: float) = when nimvm: @@ -98,7 +98,7 @@ proc addFloatSprintf*(result: var string; x: float) = else: var buffer {.noinit.}: array[65, char] let n = writeFloatToBufferSprintf(buffer, x) - result.addCstringN(cstring(buffer[0].addr), n) + result.addCstringN(cast[cstring](buffer[0].addr), n) proc nimFloatToString(a: float): cstring = ## ensures the result doesn't print like an integer, i.e. return 2.0, not 2 |