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

Can you DLLExport a generic function?

Ranbir_Singh_Shoker
621 Views

In a previous post (2003) it is stated that you cannot DLLExport a generic function and that you have to export each individual routine, i.e. in the code belowyou cannotexport M_TO_STRING, only M_INT_TO_STRING etc.? Does anyone know if this situation has changed or will change in the near future?

Thanks

Ranbir

INTERFACE M_TO_STRING

MODULE PROCEDURE M_INT_TO_STRING

MODULE PROCEDURE M_REAL_TO_STRING

MODULE PROCEDURE M_LOGICAL_TO_STRING

END INTERFACE M_TO_STRING

0 Kudos
4 Replies
Steven_L_Intel1
Employee
621 Views

It is not going to change. There is not a real function M_TO_STRING to export. For Fortran code, you don't need to export M_TO_STRING - any Fortran code that uses the module will determine which of the specific procedures to call and will use its specific name - which then needs to have been DLLEXPORTed.

If you're calling this from some other language, how do you expect it to figure out which signature to use?

0 Kudos
Ranbir_Singh_Shoker
621 Views

Thanks, I see how you're supposed to do it now. As a follow on, I'm also having trouble exporting a routine which expects a passed length characteras an argument. For example the code below produces an error during compilation. Does this mean you can only have fixed length characters as arguments for exported functions?

INTEGER FUNCTION M_LATLONG_FROM_STRING (K_LATLONG, J_LAT, J_LONG)

& RESULT ( J_ERR )

!DEC$ATTRIBUTES STDCALL, DLLEXPORT :: M_LATLONG_FROM_STRING

!DEC$ATTRIBUTES ALIAS : "M_LATLONG_FROM_STRING" :: M_LATLONG_FROM_STRING

!DEC$ATTRIBUTES REFERENCE :: K_LATLONG

!DEC$ATTRIBUTES REFERENCE :: J_LAT

!DEC$ATTRIBUTES REFERENCE :: J_LONG

CHARACTER(LEN=*), INTENT (IN) :: K_LATLONG

INTEGER, INTENT (OUT):: J_LAT

INTEGER, INTENT (OUT):: J_LONG

0 Kudos
Ranbir_Singh_Shoker
621 Views
I've found the answer to my own question - if I remove the directive relating to k_latlong, the string is passed with a length value which then means it can compile.
0 Kudos
Steven_L_Intel1
Employee
621 Views
As you found, it is not the DLLEXPORT that is the problem. When you say REFERENCE for a character argument, you're saying that no length is passed. This is incompatible with LEN=* in the character declaration.
0 Kudos
Reply