mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-30 18:41:45 +00:00
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>
This commit is contained in:
@@ -8,7 +8,7 @@ proc c_sprintf(buf, fmt: cstring) {.importc:"sprintf", header: "<stdio.h>", vara
|
||||
|
||||
proc floatToStr(f: float64): string =
|
||||
var buffer: array[128, char]
|
||||
c_sprintf(addr buffer, "%.16e", f)
|
||||
c_sprintf(cast[cstring](addr buffer), "%.16e", f)
|
||||
result = ""
|
||||
for ch in buffer:
|
||||
if ch == '\0':
|
||||
|
||||
Reference in New Issue
Block a user