Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26749 Discussions

DLLEXPORT for derived type constructor

DataScientist
New Contributor III
96 Views

Suppose we have a derived type

module this_mod

    type :: this_type
        integer :: foo
    contains
        procedure :: bar
    end type this_type

    interface this_type
        module procedure :: constructThis
    end interface this_type

contains

    function constructThis() result(This)
        !DEC$ ATTRIBUTES DLLEXPORT :: constructThis
        type(this_type) :: This
    end function constructThis

end module this_mod

Is this a proper way to export the constructor of this_type? or should the exported name be the same as the derived type's name this_type?

0 Kudos
2 Replies
FortranFan
Honored Contributor II
96 Views

A. King wrote:

.. or should the exported name be the same as the derived type's name this_type?

You should be able to use ALIASing facility with !DIR$ ATTRIBUTES to export the name of your choice, otherwise it must be the name of the procedure plus you may need decorations depending on the calling conventions in effect (e.g., STDCALL).

Steve_Lionel
Black Belt Retired Employee
96 Views

The way you did it is correct. 

Reply