Re: Problem in calling c programs and compiling them in tcl/tk



Alexandre Ferrieux wrote:
On Nov 11, 11:23 am, vasavi.n...@xxxxxxxxx wrote:
Hello,
I have been assigned to open a directory with c
programs in it using tcl/tk. Later I am supposed to c ompile all those
c programs in that directory one after another using tclk/tk.
I am able to open the directory and read all the c files. But when it
comes to compiling them am not able to do it at all. I have tried
using exec gcc filename.c and later exec ./a.out filename.c. For
example , if i take helloworld.c program & write above 2 steps , its
showing the o/p as "helloworld" . But it's also saying like child
process exited abnormally. Please can one suggest a simple command to
execute c programs . All the fork and thread concepts are quite new
and confusing to me. Isn't there any simple command in tcl from which
i can call a c program and compile it ?
I have spent nearly 4 days about this problem.But no idea at all.
Please if anyone can solve this , reply soon , if possible with an
example . I am supposed to complete it with in 1 day more.

You're being hit by the one single worst design mistake in Tcl's
history: the fact that [exec] barfs by default if the child process
writes to its stderr. That's stupid, idiot, dumb, and criminal. That
helped detect errors in one or two long-dead programs that failed to
use their exit status for abnormal exits, and that has spoilt the Tcl
experience of just about everyone else ever since :-)

The fix is trivial: [exec ... 2>@ stderr].

Or [exec -ignorestderr ...]

As you say, the workaround is trivial, and you can easily wrap it:

interp alias {} myexec {} exec -ignorestderr

If the "single worst design mistake in Tcl" is really something with a trivial 1-line fix, then Tcl must surely be perfection!

-- Neil
.



Relevant Pages

  • Re: Problem in calling c programs and compiling them in tcl/tk
    ... using exec gcc filename.c and later exec ./a.out filename.c. ... Please can one suggest a simple command to ... use their exit status for abnormal exits, and that has spoilt the Tcl ...
    (comp.lang.tcl)
  • Re: Problem in calling c programs and compiling them in tcl/tk
    ... using exec gcc filename.c and later exec ./a.out filename.c. ... use their exit status for abnormal exits, and that has spoilt the Tcl ... That won't help for the stderr writes of gcc... ...
    (comp.lang.tcl)
  • Re: open command
    ... if using exec to open something it inconsistently hangs the program ... which one hangs. ... runs on one embedded version that is where I write my tcl code, ... If it is embedded tcl version. ...
    (comp.lang.tcl)
  • Re: Q: How to determine if a process has been terminated
    ... parent process you get the pid returned from the fork call; ... any pid and delete it from the list, ... calls to exec (which is actually called "system" in the C/ APUE ... There seems to be no set of corresponding commands in Tcl though. ...
    (comp.lang.tcl)
  • Re: Catch result of external program using exec (in linux)
    ... Les Cargill wrote: ... Plain 'exec' should do the trick as well if the other program ... He wants to capture the output in his Tcl script. ... Oh, and with a pipe, one can use fileevent and the event loop ...
    (comp.lang.tcl)