Peter,
On 2005 Jan 26 , at 12.41, Peter W. Draper wrote:
> hmm, I thought this all sounded vaguely familiar and now I'm looking at
> it, it is (sorry should have remembered earlier). GAIA used to define
> these symbols many years ago, until NDF obtained its C interface. At
> that
> time Rodney introduced a new function "ndfInit" which you are supposed
> to
> call from your C/C++ main function to make sure that argc and argv are
> available to Fortran/NDF. Indeed this function has the lines:
>
> /* On Linux, we need to define these global variables which are
> referenced by the Fortran system routine GETARG. GETARG is not
> actually called if ndfInit has been used, but the linker resolves
> the reference to these variables by pulling in a function called
> ``main'' from a standard library, which then conflicts with the
> user's ``main''. */
> #if defined( LINUX )
> int f__xargc;
> char **f__xargv;
> #endif
It might be worth resuscitating the FC_SETARG macro in starconf.m4.in.
See revision 1.80 in
<http://cvsweb.starlink.ac.uk/cvsweb.cgi/buildsupport/starconf/
starconf.m4.in>. When called in configure.ac, that defined the macro
FC_SETARG(argc,argv) to be either f_setarg(argc,argv) if it was using
g77, and a null expansion otherwise. That meant that ccdwish.c
revision 1.16
<http://cvsweb.starlink.ac.uk/cvsweb.cgi/applications/ccdpack/
ccdwish.c> could call FC_SETARG(argc,argv) unconditionally.
I took this back out when I decided it was neater for ccdwish.c and the
corresponding dipso C main to be linked with the Fortran compiler, but
it sounds like it might actually be useful again for this situation,
where we need the C++ compiler to do the link. It's probably better
than conditionalising on __GNUC__, since this macro in starconf.m4.in
is a convenient locus for doing any other magic which turns out to be
required in this situation.
Perhaps it would be better named
FC_INITIALISE_FORTRAN_RUNTIME(argc,argv) or something. That would
cover this case and any others that cropped up.
Norman
--
----------------------------------------------------------------------
Norman Gray : Physics & Astronomy, Glasgow University, UK
http://www.astro.gla.ac.uk/users/norman/ : www.starlink.ac.uk
|