C calls to Fortran with strings
Mon Nov 20 07:59:00 GMT 2000
On Mon, 20 Nov 2000 16:29:32 +0100, email@example.com wrote:
> I am using the gcc compiler under Cygwin on a NT platform for applications
> where I call Fortran subroutines from C code. This is working smoothly with
> one strange exception: If more than one string are present in Fortran
> subroutines the program crashes. Apparently everything works with ONE string
> only. The following simple example illustrates the problem:
> extern void sub1_(char *s1, unsigned int);
> extern void sub2_(char *s1, unsigned int, char *s2, unsigned int);
> SUBROUTINE SUB1(S1)
> SUBROUTINE SUB2(S1, S2)
If my memory serves me right, you have defined the SUB2 wrongly.
The correct definition should be:
extern void sub2_ (char *s1, char *s2, unsigned l1, unsigned l2);
As I recall the string lengths always come after all the real formal
parameters (not directly after the string pointer).
(I can't check it at the moment so please check it and report back).
@@@@@@ @@@ @@@@@@ @ @ Ehud Karni Simon & Wiesel Insurance agency
@ @ @ @@ @ Tel: +972-3-6212-757 Fax: +972-3-6292-544
@ @ @ @ @ @@ (USA) Fax and voice mail: 1-815-5509341
@ @ @ @ @ @ Better Safe Than Sorry
Want to unsubscribe from this list?
Send a message to firstname.lastname@example.org
More information about the Cygwin