Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Problem calling Fortran DLL

Cliff
Beginner
422 Views

I am trying to call a Fortran DLL from VC++.

The IVF code is something like:

module Types

type errorType

sequence

integer*4Error_Flag

character*512Error_Msg

end type errorType

end module Types

subroutine myRoutine(error)

!dec$attributes dllexport, default, stdcall, decorate, alias: 'myRoutine' :: myRoutine

!dec$attributesreference :: error

use Types

...

write(error%error_Msg,*) 'Error: in myRoutine'

return

end subroutine myRoutine

The C++ header code is something like

#ifdef __cplusplus

extern "C" {

#endif

struct errorType

{

unsigned char error_flag;

char error_msg[512];

};

void __stdcall myRoutine

(

errorType* error

);

#ifdef __cplusplus

}

#endif

The problem I have is that when I callthe FORTRAN routine the error_msg variable is correctly set but returns empty.

Can anyone offer some insight, the actually code is more complicated (additional arguments etc) but I hope I have caught the essence of it.

Thanks for your time

Cliff

0 Kudos
1 Reply
anthonyrichards
New Contributor III
422 Views

In your routine, should you not includea TYPE declaration for your argument ERROR. i.e..

TYPE (ERRORTYPE) ERROR

?

And what is an 'unsigned character' in your C++ Structure??

0 Kudos
Reply