summary refs log tree commit diff stats
path: root/lib/system/ansi_c.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system/ansi_c.nim')
-rw-r--r--lib/system/ansi_c.nim21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/system/ansi_c.nim b/lib/system/ansi_c.nim
index af34060d8..552962775 100644
--- a/lib/system/ansi_c.nim
+++ b/lib/system/ansi_c.nim
@@ -111,22 +111,27 @@ type c_sighandler_t = proc (a: cint) {.noconv.}
 proc c_signal(sign: cint, handler: proc (a: cint) {.noconv.}): c_sighandler_t {.
   importc: "signal", header: "<signal.h>", discardable.}
 
-proc c_fprintf(f: File, frmt: cstring): cint {.
+type
+  CFile {.importc: "FILE", header: "<stdio.h>",
+          incompletestruct.} = object
+  CFilePtr* = ptr CFile ## The type representing a file handle.
+
+var
+  cstderr* {.importc: "stderr", header: "<stdio.h>".}: CFilePtr
+  cstdout* {.importc: "stdout", header: "<stdio.h>".}: CFilePtr
+
+proc c_fprintf(f: CFilePtr, frmt: cstring): cint {.
   importc: "fprintf", header: "<stdio.h>", varargs, discardable.}
 proc c_printf(frmt: cstring): cint {.
   importc: "printf", header: "<stdio.h>", varargs, discardable.}
 
+proc c_fputs(c: cstring, f: CFilePtr): cint {.
+  importc: "fputs", header: "<stdio.h>", discardable.}
+
 proc c_sprintf(buf, frmt: cstring): cint {.
   importc: "sprintf", header: "<stdio.h>", varargs, noSideEffect.}
   # we use it only in a way that cannot lead to security issues
 
-when defined(windows):
-  proc c_fileno(f: File): cint {.
-      importc: "_fileno", header: "<stdio.h>".}
-else:
-  proc c_fileno(f: File): cint {.
-      importc: "fileno", header: "<fcntl.h>".}
-
 proc c_malloc(size: csize): pointer {.
   importc: "malloc", header: "<stdlib.h>".}
 proc c_free(p: pointer) {.