This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug in g2c.h for calling Fortran vom C++ (not C)


On Monday 08 April 2002 15:24, Toon Moene wrote:
> Peter Englmaier wrote:
> > I used C++ to call FORTRAN and it worked fine until I upgraded to
> > Redhat 7.2 from Redhat 6.2. As explained in the g77 manual, I used the
> > g2c.h header to call the fortran subroutines from C and C++:
> >
> > #ifdef __cplusplus
> > extern "C" {
> > #endif
> >
> > #include <g2c.h>
> > void f77open_dmp(int *,int *,char *,float *, ftnlen);
> >
> > #ifdef __cplusplus
> > }
> > #endif
> >
> > This worked fine with older Versions of both C and C++, but with the
> > new version gcc 2.96 (included in Redhat 7.2) as well as gcc 3.0.1 (also
> > included in Redhat 7.2) it stopped working with C++. Apparently, some
> > internal variables are no longer pre-defined, namely:
> > __g77_integer, __g77_uinteger, __g77_longint, __g77_ulongint.
> > As a workaround I now define those types myself and it compiles OK.
> >
> > Please let me know, if this is (i) a gcc bug which will is/will be
> > fixed with more recent versions), or (ii) a bug from Redhat. In the
> > later case I will report the bug to Redhat as well.
>
> Well, let's call it an oversight.  __g77_integer and friends became
> internalised into the C compiler shortly before Red Hat forked its 2.96
> release.
>
> I approved that internalisation without realising that it would break
> compiling interfaces with C++ (you are the first one to complain about
> it, actually).
>
> The solution is to move these internal declarations from c-decl.c to
> c-common.c.  I'll try to come up with a patch for that (the C-like
> frontends are not my area of expertise).  It's uncertain whether it will
> be in time for the 3.1 release (which is imminent).
>
>
I ran into a similar situation recently, when I used f2c to make a framework 
for low level optimizations on a Fortran subroutine. These definitions, 
needed to compile the code written by f2c, came up missing from f2c.h and 
g2c.h, so I had to make them up myself.  In this application, I have g++ 
calling Fortran which in turn calls a gcc function partly written by f2c.

-- 
Tim Prince


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]