From db73f3af2027a68e7f9d311a8096c677b6ef4523 Mon Sep 17 00:00:00 2001 From: Michał Zieliński Date: Tue, 17 Dec 2013 20:36:53 +0100 Subject: Add stdmsg (an alias to either stdout or stderr). --- lib/system.nim | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'lib/system.nim') diff --git a/lib/system.nim b/lib/system.nim index dc5a406d1..3fccb4e8b 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1947,15 +1947,13 @@ when not defined(JS): #and not defined(NimrodVM): ## The standard output stream. stderr* {.importc: "stderr", header: "".}: TFile ## The standard error stream. - ## - ## Note: In my opinion, this should not be used -- the concept of a - ## separate error stream is a design flaw of UNIX. A separate *message - ## stream* is a good idea, but since it is named ``stderr`` there are few - ## programs out there that distinguish properly between ``stdout`` and - ## ``stderr``. So, that's what you get if you don't name your variables - ## appropriately. It also annoys people if redirection - ## via ``>output.txt`` does not work because the program writes - ## to ``stderr``. + + when defined(useStdoutAsStdmsg): + template stdmsg*: TFile = stdout + else: + template stdmsg*: TFile = stderr + ## Template which expands to either stdout or stderr depending on + ## `useStdoutAsStdmsg` compile-time switch. proc Open*(f: var TFile, filename: string, mode: TFileMode = fmRead, bufSize: int = -1): Bool {.tags: [].} -- cgit 1.4.1-2-gfad0 /a> diff stats
blob: 745bbbf622c1172d19cc5bf99958b24c6da07cf2 (plain) (tree)
1
2
3
4
5
6
7
8
9