This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: mixing gfortran and C++
- From: "Gengbin Zheng" <zhenggb at gmail dot com>
- To: "Jerry DeLisle" <jvdelisle at verizon dot net>
- Cc: "Fortran List" <fortran at gcc dot gnu dot org>
- Date: Thu, 25 Oct 2007 15:05:30 -0500
- Subject: Re: mixing gfortran and C++
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=v0FKqusoOGLLTiI2CswY49sUZ/nmmqBuLErr029ynhE=; b=YHUvzcrYVqoL8vEmk54/Uvs+GCXunVj1PO189aT5bzJgHr0+IFCnTub/iVjem1AQeP1vUZqtHUx7ArsYZ9VZACKRN2l4EdM+xq5qGqW9OqIn1yxlquz9X440xAfnuiIiQ1DmOLV+xVNF2pDNReiv6e+LzPylGtUrhQnTi5vxAyI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=iaPTV+vqONy3Vum9ZP4oRCdiw6OYKaxQUs/iRTWzLrkoAxtoWwAz9dwNrX6278p8g0cNN4sknIh0gvyRbAJwhMVtyEdQ0o1B37jgx9rZ9IjbMVMzyIuUCWEvX8veqavdYDVLr1a6hTZGNrC9LxjaKagozfuCA7Im+FOmi4wF+Mo=
- References: <5d07bffc0710241853t6e053353i575acd8447e5108e@mail.gmail.com> <5d07bffc0710241857n10177617ma71cd2fc8b6410d2@mail.gmail.com> <472019A1.2070602@verizon.net>
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
>