Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

unable to export procedure with integer*2 argument

David_Mccabe
Beginner
547 Views
Hello,

I seem unable to link to a dll containing a procedure whichhas an integer*2argument:

dll snippet:
[fortran]subroutine test(a) !DEC$ ATTRIBUTES DLLEXPORT, STDCALL, DECORATE,REFERENCE, ALIAS:'test' :: test integer*2 :: a write(*,*) a end subroutine test [/fortran]
calling code snippet:
[fortran] interface subroutine test(a) !DEC$ ATTRIBUTES DLLIMPORT, STDCALL, DECORATE, ALIAS:'test' :: test integer*2 :: a end subroutine test end interface[/fortran]
name decoration suggests that the argument has been promoted to an integer*4 for export from the .dll.

Is it possible to pass 2 byte integers like this?

cheers


0 Kudos
2 Replies
David_Mccabe
Beginner
547 Views
My apologies,

It links fine, the "REFERENCE" token should not be present in the first block of code, however the integer*2 does still seem to be passed as 4 bytes.
0 Kudos
Steven_L_Intel1
Employee
547 Views
A couple of things. You said REFERENCE in the DLL but not in the caller. STDCALL defaults to pass-by-value, so while you can link these, the value will not get properly received.

The decoration reflects the 4 bytes for the address in the DLL. In the caller, the 2-byte integer is indeed promoted to 4 bytes for pass-by-value, as this is the convention on Windows.
0 Kudos
Reply