Hello!
In a DLL I have code that performs real and complex number addition.
I put the two subroutines (real and complex addition) in a module and overloaded the interface.
The problem is that I want to export only one routine, i.e. the overloaded interface.
I included the code below:
How do I export the overloaded interface "add"?
Thank you for your suggestions.
In a DLL I have code that performs real and complex number addition.
I put the two subroutines (real and complex addition) in a module and overloaded the interface.
The problem is that I want to export only one routine, i.e. the overloaded interface.
I included the code below:
moduleoutput implicitnone private public::add !dec$attributesdllexport,c,reference,alias:'add'::add interfaceadd moduleprocedureradd,cadd endinterfaceadd contains subroutineradd(a,b,x) implicitnone real,intent(in)::a,b real,intent(out)::x x=a+b endsubroutineradd subroutinecadd(a,b,x) implicitnone complex,intent(in)::a,b complex,intent(out)::x x=a+b endsubroutinecadd endmoduleoutput
How do I export the overloaded interface "add"?
Thank you for your suggestions.
連結已複製
5 回應
You don't - that's not how it works. Your module makes "add" the only public symbol for users of the module. But you must export from the DLL all of the specific routines that "add" can resolve to. "add" is not a callable routine, it's a generic interface that the compiler sorts out.
Ok. Thank you Steve.
I exported each routine individually and added this to the main program:
Everything works fine now.
I exported each routine individually and added this to the main program:
interfaceadd subroutineradd(a,b,x) !dec$attributesdllimport,c,reference,alias:'radd'::radd !dec$attributesreference::a,b,x implicitnone real,intent(in)::a,b real,intent(out)::x endsubroutineradd subroutinecadd(a,b,x) !dec$attributesdllimport,c,reference,alias:'cadd'::cadd !dec$attributesreference::a,b,x implicitnone complex,intent(in)::a,b complex,intent(out)::x endsubroutinecadd endinterfaceadd
Everything works fine now.
Yes - typically you would provide the LIB and MOD to the user of your code. If you make the library project a dependent of the main project, the compiler will see the .mod file from the library automatically (that is new in Composer XE 2011).