Creating a FORTRAN interface to a C function that returns a char*

后端 未结 7 1347
天涯浪人
天涯浪人 2020-12-01 10:11

I\'ve been held up on this for about a week, now, and have searched forum after forum for a clear explanation of how to send a char* from C to FORTRAN. To make the matter m

7条回答
  •  -上瘾入骨i
    2020-12-01 10:31

    I always struggle with these interoperability features. I think that your interface should declare

    CHARACTER(KIND=C_CHAR),DIMENSION(*) :: getlasterrormessage
    

    and that, when you call the function, you pass a corresponding Fortran character variable with a length equal to or greater than the length of the array of C characters you expect to return.

    Since you seem to have Intel Fortran, look through the code samples provided, they give a complete example for this.

    I guess you know that what you have posted is not syntactically correct Fortran ?

提交回复
热议问题