From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,b3e01e5c19d8e617 X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1994-08-11 06:56:41 PST Newsgroups: comp.sys.dec Path: bga.com!news.sprintlink.net!news.onramp.net!convex!news.duke.edu!MathWorks.Com!europa.eng.gtefsd.com!newsxfer.itd.umich.edu!uunet!EU.net!CERN.ch!news From: danpop@cernapo.cern.ch (Dan Pop) Subject: Re: fortran + c application linker bug??? Message-ID: Sender: news@news.cern.ch (USENET News System) Organization: CERN European Lab for Particle Physics References: Date: Wed, 10 Aug 1994 14:49:35 GMT In muzic@ds2.uh.cwru.edu (Ray Muzic) writes: >I am customizing a public domain code which is mainly fortran (program + >approx 300 subroutines and functions) but has a collection of c routines >that do plotting via xwindows. The fortran code defines a function screen >and the c code defines an int screen. When I build this application I get >an access violation when the c routine tries to assign the value zero to >screen. This makes sense because according to the debugger, >screen is considered top be a function. Moreover, when I changed the >name screen to rscreen in the c code, the program works fine. > >My questions are these: >1) Is this a bug? Should c and fortan keep their own copies of screen? Yes, this is a bug. Nobody guarantees separate copies of screen. >1) Why does this program work correctly on other (Unix) platforms? Is it > because some platforms append underscores, capitalize, or otherwise > modify variable names of fortran variables? On many Unix platforms, the Fortran screen becomes _screen_ after compilation and the C screen becomes _screen. No conflict. In Unix, any program ends up being linked with the C library. But the Fortran library contains some functions with the same name as functions from C library. This trick solves the problem. The preceding underscore is added to avoid conflicts between the user symbols and the symbols used internally by the C library. >2) Is there a way to link things differently to solve this problem for VMS? I don't think so. Dan -- Dan Pop CERN, CN Division Email: danpop@cernapo.cern.ch Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland