Pascal --> C question

Dave Jones djones at megatest.UUCP
Wed Mar 16 09:25:55 AEST 1988


in article <2351 at bsu-cs.UUCP>, dhesi at bsu-cs.UUCP (Rahul Dhesi) says:
> 
> In article <12340 at brl-adm.ARPA> TLIMONCE%DREW.BITNET at 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:  <backbones>!{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 at riacs.ARPA



More information about the Comp.lang.c mailing list