From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,b7bd4802d94cf676,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-01-29 00:13:49 PST Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!paladin.american.edu!howland.reston.ans.net!spool.mu.edu!caen!batcomputer!cornell!uw-beaver!cs.ubc.ca!unixg.ubc.ca!reg.triumf.ca!fwj From: fwj@reg.triumf.ca (JONES,FRED_W.) Newsgroups: comp.sys.dec Subject: Mixed Fortran/C porting to VMS - SUMMARY Date: 28 Jan 1993 16:51 PST Organization: TRIUMF: Tri-University Meson Facility Distribution: world Message-ID: <28JAN199316515232@reg.triumf.ca> NNTP-Posting-Host: reg.triumf.ca News-Software: VAX/VMS VNEWS 1.41 Thanks to those who replied to my query about a problem porting a large mixed Fortran/C application from UNIX to VMS. [The problem is that UNIX Fortran compilers suffix all external routine and common names with an underscore while VMS Fortran does not, making the source code non-portable unless you put in alternate declarations, bracketed with #ifdef VMS, for the relevant C functions and structs, which in my case are many.] I was hoping that there might be a simple solution to this problem that I wasn't aware of, e.g. a compiler or linker switch. Ray Bellis pointed out that some Unix compilers have a no-underscore switch. Our Ultrix Fortran does, but not the MIPS Fortran we use on SGI machines. Ray, and Arne Vajhxj, gave me examples of cpp macros that will do the job, e.g.: #ifdef VMS #define F77symbol(x) x #else #define F77symbol(x) x##_ #endif ... struct { ... } F77symbol(edgr_mx); void F77symbol(mxshell)(i, a) { } This is more elegant than the in-line #ifdefs, but still not too readable. In a similar vein, Bob Tapp mentioned a package from CERN called CFORTRAN that provides a completely transparent platform-independent calling interface between Fortran and C. It involves a 900-line include file full of cpp stuff and seems like overkill for my problem. On the VMS side, Terry Poot's posting suggested checking out the Linker, but my (non-expert) reading of the Linker manual didn't reveal any obvious kosher way to play with symbol names. Another possibility might be some sort of code similar to sharable-image transfer vectors, written in MACRO. In summary, it appears that there is no quick-and-clean solution and I decided to just stick with the #ifdef bracketing. However, my office-next-door neighbour suggested the following way to get the same result without cluttering up the main body of the code: #ifdef VMS #define name1_ name1 #define name2_ name2 ..etc. #endif This is still some work, but has the virtue of simplicity. I didn't hear from any DEC people on this issue -- I wonder if they have addressed it. There are a lot of large Fortran applications around that are candidates for X Window front ends, and mixed Fortran/C programming may become more common. Fred Jones TRIUMF fwj@reg.triumf.ca