On Wed, 31 Aug 2005, Peter W. Draper wrote:
> On Tue, 30 Aug 2005, Tim Jenness wrote:
>
>>> I wondered if it would be better to say define the default function
>>> returned by FC_MAIN:
>>>
>>> FC_MAIN([pkg_dummy_main])
>>>
>>> the default being as now (main).
>>>
>>
>> That would work but you would still need to compare the result with what
>> you put in.
>
> Not with a "void AC_FC_MAIN() {}" declaration. That's the complete
> function. In fact doesn't that explain why you are not getting g95
> initialised, this isn't a call to AC_FC_MAIN, it's some duplicate.
>
No. Because if you are hoping to use the Fortran entry point you need to
make sure that FC_MAIN is your Fortran Main. If it isn't the Fortran main
(but your default or main()) then you would need to call cnfInitRTL and
declare the dummy MAIN_ in addition.
>> The best idea is to undef FC_MAIN completely but that is seriously bad
>> for backwards compatibility (although it's not clear how useful it is at
>> the moment).
>
> For backwards compatibility, my way would work automatically, or you could
> use FC_MAIN([main]), and try to make the default result undefined.
>
>> g95 forces me to do something though since I have to decide whether I'm
>> using a Fortran main (so don't need cnfInitRTL) or whether I'm using a C
>> main (and so I do need cnfInitRTL) but all whilst making sure that even if
>> I'm using a C main I still need to define MAIN_ for g95...
>
> So what is that extra definition of MAIN_ for? Is it an unresolved
> reference in the g95 shareable library?
>
YES :-)
g95 libf95 has a main() for the C main and a MAIN_ that is not defined but
is used to call the fortran PROGRAM. If you try to link a C program
against a fortran library there is no MAIN_ defined so you can't link it
unless you create a dummy MAIN_ (since you are in general using a C main
when linking against the fortran library that overrides the main() in
libf95).
So:
- If I am using a fortran entry point from C I don't want to define
main() but I do need to make sure my main is MAIN_
- If I am using a C main I need to initialise the Fortran runtime
library and then make sure that my MAIN_ symbol is resolved.
This is why FC_MAIN returning "main" is such a nightmare. If it was undef
if there was no fortran MAIN entry then the logic in the C program is much
simplified.
My backwards compatibility comment was because I was assuming that
AC_FC_MAIN was a preexisting fortran autoconf macro and not one added by
Norman. If it was added by Norman then making it default to undef would be
the right thing to do.
--
Tim Jenness
JAC software
http://www.jach.hawaii.edu/~timj
|