This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
C/Fortran integration and string passing
- From: "Pat Gunn" <pgunn at dachte dot org>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 17 Oct 2002 10:42:22 -0500
- Subject: C/Fortran integration and string passing
Hello,
I'm trying to pass strings from C code to a function
which recieves strings like this:
SUBROUTINE PSTR( STRING )
CHARACTER* (*) STRING
PRINT *, ' STRING IS ', LEN(STRING), ' CHARACTERS LONG'
PRINT *, ' STRING: [ ', STRING, ' ] '
END
Unfortunately, while I can easily call that from
Fortran, and while I have managed to integrate a number
of other functions with different types, I'm unable to determine
how strings should be passed to that. Things I've tried:
1) Making something like:
struct descriptor
{
unsigned short length;
unsigned char data_type, /* = 14 */
dsc_class; /* = 1 */
char *string_ptr;
};
and filling that out and passing it to the function. This was suggested
on an integration guide, but it might've been intended for another fortran
compiler.
2) Passing a char* and then a short with the length of that string
I haven't had any luck. If anyone can tell me what kind of argument(s)
pstr_() should get, from a C perspective, I would be very grateful.
Naturally, I'm using GCC and G77