* fortran + c application linker bug???
@ 1994-08-08 17:00 Ray Muzic
1994-08-10 14:49 ` Dan Pop
0 siblings, 1 reply; 2+ messages in thread
From: Ray Muzic @ 1994-08-08 17:00 UTC (permalink / raw)
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?
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?
2) Is there a way to link things differently to solve this problem for VMS?
Particulars
OpenVMS AXP (TM) Operating System, Version V1.5-1H1
DEC Fortran V6.1-386
DEC C V1.3-000A
c code fragment
int border_width=10, ch_flag, ch_old, ch_pixel, color_flag,
cursor_shape[]={XC_cross, XC_top_left_corner,
XC_bottom_right_corner}, depth, display_height,
display_height_mm, display_width, display_width_mm, height,
pnt_x, pnt_y, res_x, res_y, screen, width, win_flag, win_shape,
xo=0, yo=0;
fortran code fragment
The fortran code is compiled fortran/separate/nooptimize, the c code is compiled
cc/nooptimize, and the pieces are linked together fortran first, c second, options file,
vaxcrtl/library.
function screen(ar)
Line of c-code that causes access violation (DefaultScreen is the standard x macro).
screen=DefaultScreen(display);
Ray Muzic
--
* Ray Muzic, Jr., Ph.D. | "I try not to think, it slows the progress." - rfm2 *
* muzic@ds2.uh.cwru.edu | Biomedical Engr, CWRU & Image Analysis Ctr, UH __o *
* Voice: (216)-844-3543 | Div. Nuclear Medicine, Univ Hosp of Cleveland -\<, *
* Fax: (216)-844-3106 | 11100 Euclid Ave, Cleveland, OH, 44106, USA....O/ O *
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: fortran + c application linker bug???
1994-08-08 17:00 fortran + c application linker bug??? Ray Muzic
@ 1994-08-10 14:49 ` Dan Pop
0 siblings, 0 replies; 2+ messages in thread
From: Dan Pop @ 1994-08-10 14:49 UTC (permalink / raw)
In <muzic.776365235@ds2.uh.cwru.edu> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1994-08-10 14:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-08-08 17:00 fortran + c application linker bug??? Ray Muzic
1994-08-10 14:49 ` Dan Pop
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox