|
From: Brian C. B. <bcb...@ya...> - 2001-06-18 20:10:57
|
Hi,
I apologize for not being clear. I am coding a small IDE that invokes the
GCC compiler, just like Dev-C++ does. Dev-C++ catches the output produced by
GCC and displays the errors, warnings, and other GCC output at the bottom of
the program. I would like to know how to do just that: invoke GCC from my
program, catch the output, and display it. I know how to invoke GCC and
display any output, but I do not know how to catch the output. Could someone
point me in the right direction? Thanks in advance.
Sincerely,
Brian
"Shall we accept good from God, and not trouble?" Job 2:10
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]On Behalf Of Steve D.
Perkins
Sent: Monday, June 18, 2001 1:10 PM
To: dev...@li...
Subject: Re: [Dev-C++] Reading GCC output
Umm... write a program called 'foo.cpp', compile it to form 'foo.exe',
go to a command-prompt and type:
c:\YourDir\foo.exe > YourOutputFile.txt
"Piping" isn't something you do at compile-time, it's something you do
at run-time... to direct an application's input and/or output to or from a
location other than it was coded for at compile-time.
Cheers,
Steve
----- Original Message -----
From: Brian C. Becker
To: devcpp
Sent: Monday, June 18, 2001 12:03 PM
Subject: [Dev-C++] Reading GCC output
Hi,
I am trying to read the output of the gcc compiler like Bloodshed
Dev-C++ does and am not being successful. I tried looking in the online gcc
manual for command line options that might direct the output into a file,
but did not find such an option. I also read that gcc uses temp files to
communicate between the compiler, assembler, linker, etc, but could not find
any information on how to find those files to read them. I also tried the
using the "-pipe" command and that did not work; I also tried the following
code to pipe the output into my program. It works for other console programs
but outputs garbage when I try to read the output of gcc (perhaps because
gcc calles other proccesses? ):
long i;
HANDLE rh;
HANDLE wh;
STARTUPINFO stinfo;
PROCESS_INFORMATION pinfo;
DWORD bytesread;
char buf[65536];
SECURITY_ATTRIBUTES sattr;
akostring output;
HANDLE oldwh;
ZeroMemory(&sattr, sizeof(SECURITY_ATTRIBUTES));
sattr.nLength = sizeof(SECURITY_ATTRIBUTES);
sattr.lpSecurityDescriptor = 0;
sattr.bInheritHandle = true;
CreatePipe(&rh, &wh, &sattr, 0);
oldwh = GetStdHandle(STD_OUTPUT_HANDLE);
SetStdHandle(STD_OUTPUT_HANDLE, wh);
ZeroMemory(&stinfo, sizeof(STARTUPINFO));
stinfo.cb = sizeof(STARTUPINFO);
stinfo.lpReserved = 0;
stinfo.lpReserved2 = 0;
stinfo.cbReserved2 = 0 ;
stinfo.lpDesktop = 0;
stinfo.lpTitle = 0;
stinfo.dwFlags = STARTF_USESHOWWINDOW;
stinfo.wShowWindow = SW_HIDE;
if(!CreateProcess(0, "C:\\WINDOWS\\TEMP\\AkoClass\\compiler\\bin\\g++
\"C:\\WINDOWS\\TEMP\\AKOCLASS\\OUTPUT.cpp\" -c -s -mwindows -O1 -O3 -fexpens
ive-optimizations -IC:\\WINDOWS\\TEMP\\AkoClass\\compiler\\INCLUDE\\ -IC:\\W
INDOWS\\TEMP\\AkoClass\\compiler\\INCLUDE\\G__~1 -IC:\\WINDOWS\\TEMP\\AkoCla
ss\\compiler\\INCLUDE\\ -LC:\\WINDOWS\\TEMP\\AkoClass\\compiler\\LIB\\ -BC:\
\WINDOWS\\TEMP\\AkoClass\\compiler\\BIN", 0, 0, false, CREATE_NEW_CONSOLE |
NORMAL_PRIORITY_CLASS, 0,0, &stinfo, &pinfo)){
MessageBox(0,"Error","Failed",0);
}
else{
WaitForSingleObject(pinfo.hProcess, INFINITE );
CloseHandle(wh);
SetStdHandle(STD_OUTPUT_HANDLE, oldwh);
output = "";
ReadFile(rh, &buf, 65536, &bytesread, NULL);
output = (char*) &buf;
CloseHandle(pinfo.hProcess);
CloseHandle( pinfo.hThread );
}
//Note: akostring is a string class.
// output now contains garbage or nothing
Could anybody help me with this problem? Thanks in advance.
Sincerely,
Brian
"Shall we accept good from God, and not trouble?" Job 2:10
---
Outgoing mail is certified Virus Free by AVG
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.256 / Virus Database: 129 - Release Date: 5/31/2001
|