summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/ansi_c.nim10
-rw-r--r--lib/system/io.nim11
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/system/ansi_c.nim b/lib/system/ansi_c.nim
index b9f719d9e..55e004f6e 100644
--- a/lib/system/ansi_c.nim
+++ b/lib/system/ansi_c.nim
@@ -116,9 +116,15 @@ type
           incompleteStruct.} = object
   CFilePtr* = ptr CFile ## The type representing a file handle.
 
+# duplicated between io and ansi_c
+const stderrName = when defined(osx): "__stderrp" else: "stderr"
+const stdoutName = when defined(osx): "__stdoutp" else: "stdout"
+const stdinName = when defined(osx): "__stdinp" else: "stdin"
+
 var
-  cstderr* {.importc: "stderr", header: "<stdio.h>".}: CFilePtr
-  cstdout* {.importc: "stdout", header: "<stdio.h>".}: CFilePtr
+  cstderr* {.importc: stderrName, header: "<stdio.h>".}: CFilePtr
+  cstdout* {.importc: stdoutName, header: "<stdio.h>".}: CFilePtr
+  cstdin* {.importc: stdinName, header: "<stdio.h>".}: CFilePtr
 
 proc c_fprintf*(f: CFilePtr, frmt: cstring): cint {.
   importc: "fprintf", header: "<stdio.h>", varargs, discardable.}
diff --git a/lib/system/io.nim b/lib/system/io.nim
index 62722140f..a8f690054 100644
--- a/lib/system/io.nim
+++ b/lib/system/io.nim
@@ -35,12 +35,17 @@ type
 
 # text file handling:
 when not defined(nimscript) and not defined(js):
+  # duplicated between io and ansi_c
+  const stderrName = when defined(osx): "__stderrp" else: "stderr"
+  const stdoutName = when defined(osx): "__stdoutp" else: "stdout"
+  const stdinName = when defined(osx): "__stdinp" else: "stdin"
+
   var
-    stdin* {.importc: "stdin", header: "<stdio.h>".}: File
+    stdin* {.importc: stdinName, header: "<stdio.h>".}: File
       ## The standard input stream.
-    stdout* {.importc: "stdout", header: "<stdio.h>".}: File
+    stdout* {.importc: stdoutName, header: "<stdio.h>".}: File
       ## The standard output stream.
-    stderr* {.importc: "stderr", header: "<stdio.h>".}: File
+    stderr* {.importc: stderrName, header: "<stdio.h>".}: File
       ## The standard error stream.
 
 when defined(useStdoutAsStdmsg):