comp.lang.ada
 help / color / mirror / Atom feed
From: Dan Nagle <dnagle@erols.com>
Subject: Re: Trying to pass strings to Fortan routines
Date: Sun, 12 Aug 2001 07:17:12 -0400
Date: 2001-08-12T11:17:29+00:00	[thread overview]
Message-ID: <ppocntg7a1lqk4d2iatcd7hmt95269ubmr@4ax.com> (raw)
In-Reply-To: 3B763C53.18B8C606@mail.verizon.net

Hello,

Actually, the Fortran standard only says what a program has to be able
to do with character arguments, not how to pass them.  Popular
varieties of implementation include

-passing character, then length, for each character argument,
-passing character with all the lengths at the end
 of the calling sequence (which you have described in your post),
-and passing the address of a descriptor containing the address
 and length of the character argument.

Note that the size of the length argument can vary, if you've
got access to the documentation of the old Fortran compiler,
you may be able to guess the size of the length arguments.
Very few Fortran 77 compilers supported 4 billion character
long character variables, and you don't show what the "strlen"
macro? function? does...

Good luck!

-- 
Cheers!

Dan Nagle
Purple Sage Computing Solutions, Inc.

On Sun, 12 Aug 2001 04:54:59 GMT, Jack Scheible
<vze26j9s@mail.verizon.net> wrote:

>One of the promises of Ada was that one could use old libraries with the
>Interfaces packages.  It's not going so well.  I have some old FORTRAN
>libraries, and some of the routine accept CHARACTER*(*) arguments.  When
>FORTRAN makes a subprogram call with one or more "string" arguments, it
>passes the lengths of those strings as arguments _after_ all the
>declared arguments.  I can get this to work with C.  So if I call
>
>      SUBROUTINE SUB( S1, S2 )
>      CHARACTER*(*) S1, S2
>
>with the C statement
>
>      sub_( s1, s2, strlen(s1), strlen(s2) );
>
>All is well.  If I try the same thing in Ada (gnat), I get a Constraint
>Error exception.
>
>Actually, I get a Constraint Error if I just pass a String and anything
>else.
>
>Any ideas?
>
>Thanks.
>
>-jack




  parent reply	other threads:[~2001-08-12 11:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-12  4:54 Trying to pass strings to Fortan routines Jack Scheible
2001-08-12  5:24 ` tmoran
2001-08-12 11:17 ` Dan Nagle [this message]
     [not found] <3B765238.6F013AD3@mail.verizon.net>
2001-08-12  7:14 ` tmoran
2001-08-12 15:28   ` Jack Scheible
2001-08-12 18:17     ` tmoran
2001-08-13 18:28       ` Jack Scheible
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox