panicoverride.nim 652 B

123456789101112131415161718192021222324
  1. proc printf(frmt: cstring) {.varargs, importc, header: "<stdio.h>", cdecl.}
  2. proc exit(code: int) {.importc, header: "<stdlib.h>", cdecl.}
  3. proc nimToCStringConv(s: NimString): cstring {.compilerProc, inline.} =
  4. if s == nil or s.len == 0: result = cstring""
  5. else: result = cstring(addr s.data)
  6. {.push stack_trace: off, profiler:off.}
  7. proc rawoutput(s: string) =
  8. printf("%s\n", s)
  9. proc panic(s: string) {.noreturn.} =
  10. rawoutput(s)
  11. exit(1)
  12. # Alternatively we also could implement these 2 here:
  13. #
  14. # proc sysFatal(exceptn: typeDesc, message: string) {.noReturn.}
  15. # proc sysFatal(exceptn: typeDesc, message, arg: string) {.noReturn.}
  16. {.pop.}