- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page