Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling a c dll function

Status
Not open for further replies.

lauale

Programmer
Oct 10, 2017
3
DE
hello,
i want to use a function from a dll program. Here is my code:

Code:
character :: infile,outfile

interface 
   subroutine dllFunction(infile, outfile) bind(C, name="main")
      use iso_c_binding, only: C_CHAR, C_NULL_CHAR
      character(1,c_char) :: infile
      character(1,c_char) :: outfile
   end subroutine dllFunction
end interface

call dllFunction(infile, outfile)

The problem that the program call iteratively the dllfunction and it should be call it only once.
The dll is writen in C. Here is the C function that it should be used.
C:
#ifdef DLLCONFIG
#define DLL_API __declspec(dllexports)
#else
#define DLL_API
#endif

DLL_API int main(char *infile, char *outfile) {

}
Any idea because call the function all the time?
Thanks
 
Is this your first attempt at using C with Fortran? If it is, try using ints first, then an int array and then char and then char array. Char arrays are stored very differently in C and Fortran.

Also don't call your routine main - the function called main has a special meaning in C>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top