Xref: utzoo comp.lang.c:11722 comp.os.vms:7828 Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!cmcl2!nrl-cmf!ames!oliveb!sun!thetone!swilson From: swilson%thetone@Sun.COM (Scott Wilson) Newsgroups: comp.lang.c,comp.os.vms Subject: Re: cpp compatiblity Unix/VMS Keywords: cpp #include VMS Message-ID: <63044@sun.uucp> Date: 5 Aug 88 17:21:41 GMT References: <134@iquery.UUCP> Sender: news@sun.uucp Reply-To: swilson@sun.UUCP (Scott Wilson) Organization: Sun Microsystems, Mountain View Lines: 45 In article <134@iquery.UUCP> matt@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 >#include >#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 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 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@sun.com Sun Microsystems uucp: ...!sun!swilson Mt. View, CA -- Scott Wilson arpa: swilson@sun.com Sun Microsystems uucp: ...!sun!swilson Mt. View, CA