autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fortran linking on NetBSD (was: autoconf-2.50 docs...)


From: Steven G. Johnson
Subject: Re: Fortran linking on NetBSD (was: autoconf-2.50 docs...)
Date: Thu, 31 May 2001 22:34:29 -0400 (EDT)

On Fri, 1 Jun 2001, Jason Beegan wrote:
> According to the source code I've been reading it *is* also a
> GNU/Linux problem.  For example, octave, algae, tela, and others have
> these hacks in the source code for GNU/Linux.  I usually just enable
> them for NetBSD as well.

Interesting...I've never had to do that myself; apparently, they fixed
this limitation in versions of GNU/Linux from the last several years.

(GNU R defines MAIN_, MAIN__, and __main.  Are there any other
possibilities?)

Sigh...it looks like we'll need to deal with this; even if we can get
around the problem with a flag on NetBSD, it sounds like there are more
systems out there than we'll have hacks for.  This means a new autoconf
test, e.g. AC_F77_MAIN_DECLARE or the like.  I'll volunteer to write it,
but how should it work?

I suppose it could define a CPP macro F77_MAIN_DECLARE that either expands
to nothing or expands to a dummy MAIN_, or whatever, depending upon the
outcome of the test.  The manual would tell users to put this somewhere in
their program if they want to link to Fortran code.

One question is how to handle C++, which should really put extern "C" {...}
around the declaration.  The ideal way to do that would be to bracket this
with #ifdef __cplusplus ... #endif, but I can't think of a way to do that
in a macro body.  Or, we could put the #ifdef in config.h, but that would
violate the usual autoconf rules.  I guess it wouldn't be such a big deal
for the manual to say that C++ users should write extern "C" {
F77_MAIN_DECLARE }.

Another question: is it sufficient to compile a dummy Fortran file (a
foobar subroutine), and link it with a dummy C program (an empty main(),
plus the MAIN__ or whatever)?  Or does the C program have to actually call
the Fortran routine for the error to occur?  I suspect not, but if so the
AC_F77_MAIN_DECLARE test will have to be intermingled with the F77
name-mangling detection.  Ugh.

> You'll probably be saddened to hear that I added something similar to
> the configure for your FFTW library in the NetBSD Packages Collection.

Shame on you for not sending a bug report!

Steven




reply via email to

[Prev in Thread] Current Thread [Next in Thread]