This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: mixing gfortran and C++


Hi Jerry,

 Thanks for your email. I found in a simple sequential test program I
wrote, long int and int do not make any difference.
 It turns out to be a strange problem with the combination of our
using dynamic shared library, and our own memory allocator.
 If I compile a statically linked binary, this problem goes away.

Gengbin

On 10/24/07, Jerry DeLisle <jvdelisle@verizon.net> wrote:
> Gengbin Zheng wrote:
> > Hi,
> >
> >  I have a question about calling a C++ function from gfortran.
> >
> >  The fortran interface of the C++ function is like this:
> >
> >       SUBROUTINE COM_SET_MEMBER_FUNCTION( WF_NAME, FUNC, &
> >               WA_NAME, INTENTS, TYPES)
> >            CHARACTER(*), INTENT(IN) :: WF_NAME, WA_NAME, INTENTS
> >            INTEGER, INTENT(IN) :: TYPES(1)
> >            EXTERNAL FUNC
> >          End SUBROUTINE COM_SET_MEMBER_FUNCTION
> >
> > so we have 3 character strings wf_name, wa_name and intents.
> > In C++ it is defined as:
> >
> > void com_set_member_function( const char *wf_str, Func_ptr func, const
> > char *wa_str, const char *intents,   const COM_Type *types, long int
> > wf_len, long int a_len, long int i_len);
> >
> I would do it like this:
>
> void com_set_member_function_( const char *wf_str, Func_ptr func, const
> char *wa_str, const char *intents,   const COM_Type *types, int
> wf_len, int a_len, int i_len);
>
> Underline after the function name, int instead of long integer.  At least this
> works for me on some functions I am doing for C. My example that works:
>
> void
> pxfexecv_ (char *path, int *lenpath, char *argv, int *lenargv,
>            int *iargc, int *ierror, int pathlen, int argvlen)
>
> Regards,
>
> Jerry
>


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