Software Archive
Read-only legacy content

External Dll

Intel_C_Intel
Employee
416 Views
hi,
We have a third party dll written in VC++.The arguments that a particular subroutine takes are given as word,long,integer in VC++.When we are assigning the datatypes for word as integer(2), for long as integer(4) and integer for integer in our interface ,it does not give any mismatch error,but it also does not result in correct execution. We are unsure of what the equivalent datatypes are in Visual Fortran for word,long,integer.Could you please help us.
-rs
0 Kudos
2 Replies
Intel_C_Intel
Employee
416 Views
int and long are both 32 bit integers in VC++, so integer(4) should match for those.
If word means unsigned short, you'll have to find a workaround, since fortran does not have 'unsigned integers'. If you've got VC++, perhaps you could write a wrapper between fortran and the dll, and handle the assignment from integer(4) <-> int <-> ushort (dll arg) from there. Search comp.lang.fortran on Google for some more alternatives for handling unsigned data types.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
416 Views
You can use integer(2) as replacement for word as long as you take care you don't mess with the most significant bit which determines the sign; in other words, if your integer(2) variable is less than 32767. Even if it is, you might play with TRANSFER intrinsic (untested):
 
integer(2):: iWord 
iWord=TRANSFER(40000_4, iWord) 

should result that iWord contains identical bit-representation as C's unsigned int 40000, meaning that C would "see" it as 40000 (though you'd see it in debugger as something like -7232).

HTH
Jugoslav
0 Kudos
Reply