- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you used a module for your routines, just USE the module in the main program. You should never have to repeat the interface. The DLLEXPORTs will magically turn into DLLIMPORTs on the USE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, but this works only if I include the path to the compiled module file (output.mod). This is in addition to referencing the .lib in the main program, which I did before anyway.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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).

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page