Path: utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!amdahl!dlb!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: Pascal --> C question Message-ID: <331@goofy.megatest.UUCP> Date: 15 Mar 88 23:25:55 GMT References: <2351@bsu-cs.UUCP> Organization: Megatest Corporation, San Jose, Ca Lines: 56 in article <2351@bsu-cs.UUCP>, dhesi@bsu-cs.UUCP (Rahul Dhesi) says: > > In article <12340@brl-adm.ARPA> TLIMONCE%DREW.BITNET@CUNYVM.CUNY.EDU writes: >>Actually, the only version of Pascal that I will use is VaxPascal under >>VMS (what's that?) because it has some [excellent] optimizations.... > ... >>Why can't popular C compilers do that? > > Another interesting optimization done by a VMS compiler, that competing > vendors never thought of doing, is this. If your C program contains > > fflush(stdout); > > the VMS C compiler will optimize this into: > > if (F$MODE == INTERACTIVE) /* if interactive run */ > fflush(stdout); > else > printf("\n"); /* if batch run */ > -- > Rahul Dhesi UUCP: !{iuvax,pur-ee,uunet}!bsu-cs!dhesi I hope the compiler doesn't do this "optimization". It is not correct. Flushing the stdio buffer should not insert a newline '\n' into the output stream. I don't know much about VMS. Is it possible to connect two processes by means of a pipe fed on the inflow side by stdout? Consider two processes, so connected, which send messages through the pipe, encoded as text. In this case, the fflush() is required to assure that a message is dispatched through the pipe. Is this application's F$MODE == INTERACTIVE? Here's a bit of code from a production program. By the way, "pt" stands for Pascal-translator. /* Send command "a" to the compile-daemon: Compile the * file named [code_file] */ fprintf(pt_input, "a\n%s\n", code_file); /* dispatch the command */ fflush(pt_input); /* wait for return code from compilation */ fscanf(pt_output, "%d", &retcode); Dave Jones Megatest Corp. 880 Fox Lane San Jose, CA. 95131 (408) 437-9700 Ext 3227 UUCP: ucbvax!sun!megatest!djones ARPA: megatest!djones@riacs.ARPA