parent
02351d02e7
commit
c7eba64dee
3 changed files with 14 additions and 8 deletions
|
|
@ -17,13 +17,6 @@
|
||||||
const
|
const
|
||||||
NilLibHandle: LibHandle = nil
|
NilLibHandle: LibHandle = nil
|
||||||
|
|
||||||
proc c_fwrite(buf: pointer, size, n: csize, f: File): cint {.
|
|
||||||
importc: "fwrite", header: "<stdio.h>".}
|
|
||||||
|
|
||||||
proc rawWrite(f: File, s: string|cstring) =
|
|
||||||
# we cannot throw an exception here!
|
|
||||||
discard c_fwrite(cstring(s), 1, s.len, f)
|
|
||||||
|
|
||||||
proc nimLoadLibraryError(path: string) =
|
proc nimLoadLibraryError(path: string) =
|
||||||
# carefully written to avoid memory allocation:
|
# carefully written to avoid memory allocation:
|
||||||
stderr.rawWrite("could not load: ")
|
stderr.rawWrite("could not load: ")
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,15 @@ var
|
||||||
## instead of stdmsg.write when printing stacktrace.
|
## instead of stdmsg.write when printing stacktrace.
|
||||||
## Unstable API.
|
## Unstable API.
|
||||||
|
|
||||||
|
proc c_fwrite(buf: pointer, size, n: csize, f: File): cint {.
|
||||||
|
importc: "fwrite", header: "<stdio.h>".}
|
||||||
|
|
||||||
|
proc rawWrite(f: File, s: string|cstring) =
|
||||||
|
# we cannot throw an exception here!
|
||||||
|
discard c_fwrite(cstring(s), 1, s.len, f)
|
||||||
|
|
||||||
when not defined(windows) or not defined(guiapp):
|
when not defined(windows) or not defined(guiapp):
|
||||||
proc writeToStdErr(msg: cstring) = write(stdmsg, msg)
|
proc writeToStdErr(msg: cstring) = rawWrite(stdmsg, msg)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
proc MessageBoxA(hWnd: cint, lpText, lpCaption: cstring, uType: int): int32 {.
|
proc MessageBoxA(hWnd: cint, lpText, lpCaption: cstring, uType: int): int32 {.
|
||||||
|
|
|
||||||
6
tests/exception/t9657.nim
Normal file
6
tests/exception/t9657.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
discard """
|
||||||
|
action: run
|
||||||
|
exitcode: 1
|
||||||
|
"""
|
||||||
|
close stdmsg
|
||||||
|
writeLine stdmsg, "exception!"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue