help-gplusplus
[Top][All Lists]
Advanced

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

Re: Fortran subroutines in c++


From: Robert Heller
Subject: Re: Fortran subroutines in c++
Date: Fri, 09 Jul 2004 12:46:36 +0200

  Amit Bhatia <bhatia2@nospam.com>,
  In a message on Fri, 09 Jul 2004 00:42:12 -0500, wrote :

AB> Hi Everyone.
AB>  I have also posted some portion of my queries to comp.lang.c++, hence I
AB> apologize for repitions.
AB> 
AB>  I wish to make a call to a fortran subroutine from a c++ class. I am
AB> reading onto it from a couple of sources on the net.
AB>  Now I have defined the following
AB> 
AB> -----util.h-----
AB> #ifndef UTIL_H
AB> #define UTIL_H
AB> 
AB> #include "common.h"
AB> 
AB> extern "C" 
AB> { 
AB>   void __stdcall DGPADM (int ideg,int m,double t, double H,int ldh,double
AB> wsp,double lwsp,int ipiv,int iexph,int ns,int iflag); 
AB> }

Note: FORTRAN params are generally passed by *reference* (as pointers):

extern "C"
{
   void __stdcall DGPADM (int *ideg,int *m,double *t, double *H,int *ldh,
                          double *wsp,double *lwsp,int *ipiv,int *iexph,
                          int *ns,int *iflag);
}

About your error:  it might be caused by the __stdcall...

AB> 
AB> int utility_methodA(\\arg list);
AB> #endif
AB> 
AB> and then 
AB> 
AB> -----util.C-----
AB> #include "util.h"
AB> #define TINY 1.e-30
AB> using namespace std;
AB> 
AB> int utility_methodA(\\arg list)
AB> {return 0;}
AB> 
AB> Now I compile this code with g++ using
AB> 
AB> g++ -c -pg -O -Wno-deprecated -ansi -pedantic   -DANSI_HEADERS
AB> -D_G_HAVE_BOOL util.C -I.
AB> 
AB> But it complains
AB> util.h:8: syntax error before `(' token
AB> 
AB> What is wrong: I can't get it? Isn't this the way one is supposed to call
AB> fortran subroutines?
AB>  And then I don't know if I need to give any special commands while linking
AB> as well: I make an archive of all *.o files using 
AB> 
AB> ar ruv libmine.a util.o (other *.o files)
AB> 
AB> and finally i link my test program using -lmine option.
AB> 
AB> tia,
AB> amit.
AB>                                                                   

                                     \/
Robert Heller                        ||InterNet:   heller@cs.umass.edu
http://vis-www.cs.umass.edu/~heller  ||            heller@deepsoft.com
http://www.deepsoft.com              /\FidoNet:    1:321/153






                                                                                
                                  


reply via email to

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