This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: No underscore option for g77 or f77
- To: Mumit Khan <khan@xraylith.wisc.edu>
- Subject: Re: No underscore option for g77 or f77
- From: "J.C. Ng" <j.c.ng@ic.ac.uk>
- Date: Mon, 10 May 1999 17:41:31 +0100 (BST)
- cc: "J.C. Ng" <j.c.ng@ic.ac.uk>, cygwin@sourceware.cygnus.com
Thanks for the info.
Actually it is gcc/g++ which appends the underscore to the front of the
symbols within the libray. And this mucks up the compilation of my
executable. How can I disable this?
On Mon, 10 May 1999, Mumit Khan wrote:
> On Mon, 10 May 1999, J.C. Ng wrote:
>
> > The library was compiled using egcs 1.1.2 in Cygwin. I used nm to check
> > the symbols within the library and all of them was prepended an
> > underscore.
> > Thanks for your help.
>
> So you're trying to call g77 compiled routines from C/C++ and vice versa
> and running the "underscore issue". There is lots of info on the net on
> how to semi-portably do this, and I won't rehash that here. Here's a quick
> summary of what I do:
>
> 1. at compile time (via configuration utility), check if the f77 compiler
> tacks an underscore at the end. If so, define F77_APPEND_UNDERSCORE to
> be 1, or else 0 (or undefine it).
>
> 2. In C headers, when prototyping the functions, I use this macro to
> declare the externals:
>
> #if F77_APPEND_UNDERSCORE
> # define F77_FUNCTION(f) f##_
> #else
> # define F77_FUNCTION(f) f
> #endif
>
> extern int F77_FUNCTION(f77func1) (int *, int *);
>
> or, if you want to define or undefine F77_UNDERSCORE (instead of giving
> it a value),
>
> #if defined(F77_APPEND_UNDERSCORE)
> # define F77_FUNCTION(f) f##_
> #else
> # define F77_FUNCTION(f) f
> #endif
>
> extern int F77_FUNCTION(f77func1) (int *, int *);
>
> You can simply build all your C code with -DF77_APPEND_UNDERSCORE=1 and
> you're all set.
>
> G77, thanks to compatibility with f2c, has one more issue -- it appends
> *TWO* underscores if the name already has an underscore. Of course, names
> with underscores are not legal in f77, so f2c is free to do as it wishes.
>
> There are good portability packages out there that may help. Lots of
> people use CFORTRAN, which is a terrific package that hides lots of this
> magic. You need to get version 3.5. Also search the mailing list for
> what else you may need.
>
> Regards,
> Mumit
>
>
>
>
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com
>
----------------------------------------------------------------------
Freddy Ng Jit Cheng
Singapore address : Blk 245 Hougang St. 22 Tel no. : 2875630
#14-147
Singapore 530245
London address : Basement Flat Tel no. : 0171-5650155
144 Lexham Gardens
London W8 6JE
Homepage : http://www.geocities.com/sunsetstrip/5030
-----------------------------------------------------------------------
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com