FAQ (Frequently Asked Questions)
for Compaq Fortran developers on using WSQ image library





How to call and use WSQ image library functions from Compaq Fortran?

In Compaq Fortran it is possible to directly call a C function in a DLL if that function uses the _cdecl calling convention. However several data types (as for example string) have different internal representations in C and FORTRAN. Therefore if the function called from DLL contains the string as the argument, special wrapper interface DLL should be used for string conversion into compatible type.

Such a wrapper interface is provided in DLL file "WSQ_library_fortranexport.dll".




How to convert Fortran string into C string?

It depends on the compiler used. The general rule is that FORTRAN appends the string size to the end of the string, while C does not append the size.

[1] Linux and GNU compilers:

When passing character strings, the length must follow as separate arguments which are passed by value.

  
FORTRAN:
  call subrA( string_a, string_b)
C:
  len_a = strlen(string_a);
  len_b = strlen(string_a);
  subra_( char *string_a, len_a, char *string_b, len_b)

[2] Classic AT&T UNIX:

When passing character strings, the length must be appended as separate arguments which are passed by value.

  
FORTRAN:
  call subrA( string_a, string_b)
C:
  subra_( char *string_a, char *string_b, len_a, len_b)

[3] Databases such as Oracle

When passing character strings, strings are converted into data structure containing two elements, the character string and an integer storing the length.

For WSQ image library please use provided wrapper DLL interface (file "WSQ_library_fortranexport.dll"), which does all the needed conversion of string data types.







Copyright ©2024 Cognaxon. All rights reserved. Privacy