Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Using BIND(C) for SetDllDirectory

$
0
0

I am able to call SetDllDirectory using the following code (found on your web https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-fo...):

INTERFACE
    FUNCTION SetDllDirectory(lpPathName)
        IMPORT
        LOGICAL(KIND=1) :: SetDllDirectory
        !DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'SetDllDirectoryA' :: SetDllDirectory
        !DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: lpPathName
        !
        CHARACTER(LEN=*) lpPathName ! LPCSTR lpPathName
    END FUNCTION
END INTERFACE

I am curious, why the function is called SetDllDirectoryA in the Alias? What is the extra A?

Now I want to use BIND(C) to do the same, but it does not work. Here is my example, but it results into link error for SetDllDirectoryA

INTERFACE
    FUNCTION SetDllDirectory(lpPathName), BIN(C, name='SetDllDirectoryA')
        IMPORT
        LOGICAL(KIND=1) :: SetDllDirectory
       CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: lpPathName
        !        
    END FUNCTION
END INTERFACE

The USE, INTRINSIC :: ISO_C_BINDING 

statement is placed in my main module declaring this interface.


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>