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

DLLEXPORT for derived type constructor

DataScientist
Valued Contributor I
368 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
368 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).

0 Kudos
Steve_Lionel
Honored Contributor III
368 Views

The way you did it is correct. 

0 Kudos
Reply