cpp compatiblity Unix/VMS

Scott Wilson swilson%thetone at Sun.COM
Sat Aug 6 03:21:41 AEST 1988


In article <134 at iquery.UUCP> matt at iquery.UUCP (Matt Reedy) writes:
>The problem is the following:  I want the same source to compile on both
>SysV and VMS, so I use this style:
>
>#ifdef VAX
>#include file
>#include stdio
>#else
>#include <fcntl.h>
>#include <stdio.h>
>#endif
>
>Is there an easy workaround?

I have worked on a few projects that compiled and ran on both Suns
and VMS with little or no special precautions.  Two of these
projects used lex and yacc output.  The solution to your problem
is simple, use the <*.h> form for both.  The VMS C compiler has
no problem with UNIX style #includes (it even allows pathnames
with '/' for compatibilty, I think).  Also, if you set some logical
that I don't remember, you can also use the <sys/*.h> form and
have the compiler look in the same directories as it does for other
standard include files.  As for the two environments using different
file names for the same declarations, I guess you'll have to use
and #ifdef for that.

One of the compatibility problems I ran into was compiling lex
output on VMS.  In UNIX, stdin, stdout, stderr are compile time
constants, however in VMS they're not so you can't use them as
initializers.  This was solved by having the Makefile run sed to remove
the offending initialization and then explicitly do it in the beginning
of main().  Another problem was that lex output wants to include "stdio.h"
as opposed to <stdio.h> and VMS is somewhat screwed about how these
differ.  This was solved by setting c$include to be the same
as vaxc$include.

-- 
--
Scott Wilson		arpa: swilson at sun.com
Sun Microsystems	uucp: ...!sun!swilson
Mt. View, CA
--
Scott Wilson		arpa: swilson at sun.com
Sun Microsystems	uucp: ...!sun!swilson
Mt. View, CA



More information about the Comp.lang.c mailing list