Quantcast
Channel: Intel® Fortran Composer XE
Viewing all articles
Browse latest Browse all 1424

passing a character string in c++ t oa dll function in Fortran

$
0
0

Hello

I have a fortran dll with a large number of functions receiving character strings as arguments

for example

double precision function func(str1,prop1,prop2,str2) BIND(C,name='cppfunc')

use, intrinsic :: ISO_C_BINDING

!DEC$ ATTRIBUTES DLLEXPORT :: func

implicit none

!define input variables

character, dimension (12), intent(in) :: str1

character, dimension(255), intent(in) :: str2

..

additional processing

on the c++ side I declare a function

extern "C"

{

double cppfunc(char *, double, double, char *);

}

then in the main c++ code I declare the following

char input[12],f[255],path[255];

strcpy_s(input,"somestring");

strcpy_s(path,"some_path");

cppfunc(input,10.0,10.0,path);

using the debugger I see that path is not defined on the fortran side of the dll and the program has an exception

is there any systematic and robust way to pass char string to a fortran function in a dll ?

 

thanks

jac

 

 


Viewing all articles
Browse latest Browse all 1424

Trending Articles