Pascal --> C question

mcdonald at uxe.cso.uiuc.edu mcdonald at uxe.cso.uiuc.edu
Thu Mar 17 23:51:00 AEST 1988


> 
> 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?

Perhaps you should understand VMS before making such comments. You see,
VMS is not a flavor of UNIX. It is an entirely different operating system.
Its file system is entirely unlike Unix's. There are many different TYPES
of files. For certain kinds of files, outputting a \n in C will flush the
buffers, AND is REQUIRED at the end of a file. Ordinary text files absolutely
must end in a way that is indicated in C by /n. No particular character
is actually placed in a file to represent this; it is indicated by the
record structure. However, what is funny is that, by default, stdout
is NOT a standard text file in the version of VMS C that we use. I seriously
doubt that such behaviour is a bug though, as I've found that VMS C works
quite well (except that stdout is not an ordinary text file.)

Any genuine VMS gurus want to give the full explanation?

Doug McDonald



More information about the Comp.lang.c mailing list