Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: tlug: Calling C procedures from FORTRAN
- To: tlug@example.com
- Subject: Re: tlug: Calling C procedures from FORTRAN
- From: Venkatesh Raghavan <raghavan@example.com>
- Date: Tue, 16 Feb 1999 11:17:57 +0900
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=iso-2022-jp
- References: <36C39982.93B1BBC9@example.com> <14019.44648.357221.369381@example.com>
- Reply-To: tlug@example.com
- Sender: owner-tlug@example.com
Hi, Thanks for your reply. I just found a g77 option to avoid appending _(underscore) to C procedure calls. This makes it easier for me to make C procedure and library call from my Fortran program. The g77 option is as shown below; >g77 -fno-underscoring -fsource-case-preserve test.f the "-fno-underscoring" is to avoid adding the underscore and "-fsource-case-preserve" is to preserve the case sensitivity in my Fortran program. I need to use the "-fsource-case-preserve" flag since g77 converts subroutine names to lower cases and my C routines that have both upper and lower cases (eg. call R_open_driver etc.) Hope this helps people who want to try Fortran/C mixed programming. Venkatesh Raghavan Osaka City University Stephen J. Turnbull wrote: > >>>>> "VR" == Venkatesh Raghavan <raghavan@example.com> writes: > > VR> I am writing a FORTRAN program that calls C procedures. I am > VR> using g77 and gcc compilers. By default the g77 compiler > VR> appends an _(underscore) to function and subroutine names. For > VR> example my program call a C procedure as follows; CALL CPROC() > > VR> and I have to name the C procedure as cproc_() > > Does this actually work? I thought FORTRAN and C had different > calling conventions. That's what those underscores are for, > preventing you from accidentally linking incompatible call sequences. > > VR> Is there any way/option for suppressing this addition of > VR> underscore in FORTRAN so that C procedures can be called > VR> directly (without adding an underscore). > > In C++, if FORTRAN linkage is supported, you can do the following > > #ifndef NAG_WRAPPER > #define NAG_WRAPPER > extern "fortran" { > > /* prototypes for NAG routines go here */ > > } > > This automatically generates the necessary thunks to make sure the > arguments are in the right order and alignment and so on. I don't > know how you would do this in FORTRAN to call C. > ------------------------------------------------------------------- Next Nomikai: March 19 (Fri), 19:30 Tengu TokyoEkiMae 03-3275-3691 Next Technical Meeting: April 10 (Sat), 12:30 place: Temple Univ. ------------------------------------------------------------------- more info: http://tlug.linux.or.jp Sponsor: PHT
- References:
- tlug: Calling C procedures from FORTRAN
- From: Venkatesh Raghavan <raghavan@example.com>
- tlug: Calling C procedures from FORTRAN
- From: "Stephen J. Turnbull" <turnbull@example.com>
Home | Main Index | Thread Index
- Prev by Date: Re: tlug: Graphic Tool
- Next by Date: Re: tlug: 10/100base2 NICs for Linux
- Prev by thread: tlug: Calling C procedures from FORTRAN
- Next by thread: tlug: Intial Window size in Wmaker
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links