delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/10/29/14:24:02

From: Divisione SINCON <sincon AT minsky DOT csata DOT it>
Subject: stderr redirection under DOS
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Date: Thu, 29 Oct 92 20:13:42 MET
Mailer: Elm [revision: 66.25]

Hello there!,
I saw people looking for a way to save the error output messages when compiling
I'm currently using this trivial program (Borland C synatx &libs)




#include <dos.h>
#include <stdio.h>
#include <io.h>
#include <stdlib.h>

#if !__COMPACT__
  #error Must use compact memory model
#endif

int main(void) {
  char far *cmd, *t;

  // Parse command line
  cmd=MK_FP(_psp,0x81);
  while ((*cmd==' ') || (*cmd=='\t')) cmd++ ; // skip leading blanks
  for (t=cmd; *t && *t!='\r'; t++)          ; // look for terminating return
  *t = '\0';                                  // convert to null
  dup2(fileno(stdout),fileno(stderr));
  return system(cmd);
}

You use it simply prepending it to the real command and you get stderr and 
stdout on the sam redirection.
something like:
errout gcc -c whatever whith options >foo.err
will send error messages and normal output to foo.err
beware that not always the two files are merged right, so if you send to file
the output of a makefile it can happen that the errors come before the line 
that caused them I haven't found a clen way to overcome this, but I don't think is a real
problem.
have fun!
Mauro Condarelli

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019