Date: Sun, 17 Jul 1994 22:30:26 +0100 To: djgpp AT sun DOT soe DOT clarkson DOT edu From: mag1007 AT hermes DOT cam DOT ac DOT uk (Martin Granell) Subject: Re: logging errors There are two decent solutions. (The third is setting the GO32 environment variable, but that has some peoblems with pre-compiling.) 1) Get 4DOS, one of the best pieces of shareware written. it allows you to redirect errors simply: gcc ...... >& errorfile (does stderr and stdout) or gcc ...... >&> errorfile (just stderr) 2) Use redirect, but it's slower (needs to load up go32 an extra time.) Here's a program that redirects stderr to stdout. Do: redirect -e gcc ....... or put it in the makefile.. or to redirect all (quicker): redirect -e make ********************** CUT HERE ************************************ /* ** redirect -- feed line to shell with stdin/stdout/stderr redirected ** ** usage -- redirect [-i newin] [-o newout] [-e newerr] command ** ** executes command via the shell, but redirects stdin/stdout/stderr first. ** stdout/stderr are appended, not overwritten. */ #include extern char *strcat( char *, char * ); extern char *strcpy( char *, char * ); extern int system( char * ); extern void exit( int ); extern int errno; char umsg[] = "usage: redirect [-i newin] [-o newout] [-e newerr] command\n"; char emsg[] = "can't redirect %s to %s\n"; void main ( int, char ** ); void main ( argc, argv ) int argc; char **argv; { int result; char buf[5120]; argc--; argv++; if (!argc) { fprintf( stderr, umsg ); exit( 0 ); } while (**argv == '-') { if (*(*argv+1) == 'i') { argc--; argv++; if (!freopen( *argv, "r", stdin )) { fprintf( stderr, emsg, "stdin", *argv ); exit( 1 ); } } else if (*(*argv+1) == 'o') { argc--; argv++; if (!freopen( *argv, "a", stdout )) { fprintf( stderr, emsg, "stdout", *argv ); exit( 1 ); } } else if (*(*argv+1) == 'e') { argc--; argv++; if (!freopen( *argv, "a", stderr )) { fprintf( stderr, emsg, "stderr", *argv ); exit( 1 ); } } else fprintf( stderr, "unknown option %c\n", *(*argv+1) ); argc--; argv++; } if (!argc) { fprintf( stderr, umsg ); exit( 0 ); } strcpy( buf, *argv++ ); while (*argv) strcat( strcat( buf, " " ), *argv++ ); if (result = system( buf )) fprintf( stderr, "exit code = %d, errno = %d\n", result, errno ); exit( 0 ); }