James Kanze
9/8/2009 9:58:00 PM
On Sep 8, 2:18 pm, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
> Francesco wrote:
> > On Sep 8, 12:07 pm, Leslaw Bieniasz <nbbie...@cyf-kr.edu.pl> wrote:
> >> Cracow, 8.09.2009
> >> In the case of console programs, the easiest thing to do is
> >> to send various messages to an output stream, during the
> >> program operation, for example:
> >> cout << "Error detected: missing right parenthesis".
> >> However, this solution does not seem the best if the same
> >> code is to run also under graphical GUI, because there is
> >> no direct way to connect the output stream to the various
> >> windows.
Just for the record, I've never seen a compiler which had a
graphical interface.
> > I think I have overlooked this point. Are you sure that you
> > cannot intercept the output? Any operating system should be
> > able to redirect the output.
> > For example, under Windows the ">" character, appended to a
> > program call, redirects the output to anything on the right
> > side of that character. For example...
> > c:\compiler.exe sourcefilename -option > messenger.exe
> I believe you've confused two separate elements of the MS-DOS
> interface. The '>' redirects the output of the left operand
> (executable) to the file specified as the right operand, while
> '|' ("pipe") redirects the output and makes it standard
> *input* of the executable on the right.
The usual solution is for the GUI (the IDE) to use something
like system() to invoke the compiler, redirecting the output to
a temporary file which it then reads and exploits, e.g.:
system( "c:\compiler.exe sourcefilename > c:\temp
\compiler.out" ) ;
> > ...redirects the output of compiler.exe to an hypothetical
> > small messenger.exe utility whose unique task is to
> > transform the output into a list which can be polled at
> > runtime via the Windows API.
> I think the command should actually be
> c:\compiler.exe sourcefilename -option | messenger.exe
I doubt the that messenger.exe is even necessary; typically, the
IDE will start the compiler in a separate thread, which then
waits for it to finish using something like the wait() system
call under Unix. It then reads the compiler output files.
--
James Kanze