Why do I get warnings when loading a DLL with LOADLIBRARY in MATLAB 7.13 (R2011b)?

17 views (last 30 days)
When I run the following code:
hfile = ['C:\Program Files\National Instruments\CVI80\include\visa.h'];
dllfile = ['C:\WINDOWS\system32\visa32.dll'];
[result, warnings] = loadlibrary(dllfile, hfile)
I obtain the following warning messages:
warnings =
Failed to parse type '...' original input ' ...'
Found on line 365 of input from line 149 of file C:\Program Files\National Instruments\CVI80\include\visa.h
Error parsing argument for function viPrintf function may be invalid.
Failed to parse type '...' original input ' ...'
Found on line 367 of input from line 151 of file C:\Program Files\National Instruments\CVI80\include\visa.h
Error parsing argument for function viSPrintf function may be invalid.
Failed to parse type '...' original input ' ...'
Found on line 371 of input from line 155 of file C:\Program Files\National Instruments\CVI80\include\visa.h
Error parsing argument for function viScanf function may be invalid.
Failed to parse type '...' original input ' ...'
Found on line 373 of input from line 157 of file C:\Program Files\National Instruments\CVI80\include\visa.h
Error parsing argument for function viSScanf function may be invalid.
Failed to parse type '...' original input ' ...'
Found on line 377 of input from line 161 of file C:\Program Files\National Instruments\CVI80\include\visa.h
Error parsing argument for function viQueryf function may be invalid.
If I load the 64-bit version of the DLL, visa64.dll, I get the following warning messages:
Warning: The data type 'error' used by function viPrintf does not exist.
> In loadlibrary at 402
Warning: The data type 'error' used by function viSPrintf does not exist.
> In loadlibrary at 402
Warning: The data type 'error' used by function viScanf does not exist.
> In loadlibrary at 402
The functions listed also do not work.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 12 Apr 2012
This is due to the function definitions in the header file visa.h being written with ellipsis (to define variable number of inputs), such as:
ViStatus viPrintf ( ViSession vi , ViString writeFmt , ...);
This is not supported by LOADLIBRARY, and the '...' input is misinterpreted as 'error' input which is undefined and causes the warning.
The workaround for this is to explicitly define the number and type of arguments for the function, by editing the prototype file (not the header file). Please see the steps below:
a. Generate the prototype file by the command
loadlibrary visa64.dll visa.h mfilename visaprototype.m
b. Unload the library
unloadlibrary visa64
c. Edit the prototype file visaprototype.m. Search for the offending function names, you will see something like below:
% ViStatus viPrintf ( ViSession vi , ViString writeFmt , ...);
fcns.name{fcnNum}='viPrintf'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='long'; fcns.RHS{fcnNum}={'ulong', 'int8Ptr', 'error'};fcnNum=fcnNum+1;
The commented part is the function signature copied from the header file visa.h. Note that the uncommented part should be on one line. Notice the third argument '...' which is unsupported by LOADLIBRARY.
If you look at the prototype line below it, fcns.name is the function name, fcns.calltype is the calling type, fcns.LHS is the output arguments, and fcns.RHS is the input arguments. We are interested in modifying the input arguments:
fcns.RHS{fcnNum}={'ulong', 'int8Ptr', 'error'}
You want to modify the 'error' argument into the signature type that you want to use. If you are not entering extra arguments, remove it entirely. Examples:
fcns.RHS{fcnNum}={'ulong', 'int8Ptr'} %no additional argument
fcns.RHS{fcnNum}={'ulong', 'int8Ptr', 'int8Ptr'} %additional int8 pointer
d. Reload the library with the modified prototype file.
loadlibrary('visa64.dll', @visaprototype)
Now you should be able to use these functions.

More Answers (0)

Products


Release

R2008a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!