06-30-2010 01:35 PM
Hi,
We are writing an application to control a spectrometer via the USB interface using Labwindows CVI 7.0.
We are trying to generate the import library for an instrument (avaspec -2048-2-USB2 spectrometer). We have the as5216.dll library and the corresponding header file as5216.h. We encountered errors when using the procedure to create the as5216.lib file in CVI 7.0. We know from the company that provided us the insrtuments and files that the DLL library they provided exports the functions in standard C (not C++) but the header file seems to contain some declarations that conflict with CVI. We are getting an error "as5216.h"(107,56) Integer expression must be constant. We have about 20 errors of this sort. We here attach the header file. Can anybody give us some clue about how to solve these errors?. Any help will be much appreciated.
Fundadero
06-30-2010 02:14 PM
Hi,
from the error message I would expect that you may not use something like
uint16 const SETTINGS_RESERVED_LEN = ((62*1024) - sizeof(uint32) -...
What should work is to calculate this length by yourself and enter a fixed number.
Wolfgang
07-01-2010 02:17 AM - edited 07-01-2010 02:18 AM
The line on error is this one:
float m_aFit[NR_WAVELEN_POL_COEF];
where you have previously defined NR_WAVELEN_POL_COEF as a char const.
It seems that CVI compiler makes a difference between a constant expression and a variable specified as const while other compilers don't.
By changing declarations as follows:
#define NR_WAVELEN_POL_COEF 5
you should be able at least to compile succesfully.
07-01-2010 03:42 AM
Hi Roberto,
I didn't try to include and compile the file provided by Fundadero, but his error message
Integer expression must be constant
suggested to me that I had to look for an integer expression, while you referred to a different line with the definition of a float... In this line there is no integer at all? I am sure you are right, but I don't understand it...
Wolfgang
07-01-2010 05:24 AM
Wolfgang,
The compiler is complaining that the array size needs to be an integer constant. Another coffee, maybe?
JR
07-01-2010 05:36 AM
Hi JR,
Thanks for the coffee
07-02-2010 02:46 AM
Hi JR,
I don't know if Fundadero has solved his problem by now - but for me this thread was quite valuable: In my aging memory I had the definition that
A header file is a file containing C declarations
This, indeed, is way too strict as I have learned in the coffee break... Thanks again for being lenient
Fundadero, sorry for the false suggestion, now I know better...
07-07-2010 10:36 PM
Dear Wolfgang, JR and Roberto,
Thanks for all your comments. We have tried to replace the declarations that used const and replaced them with precompiler #define declarations. In addition, we evaluated the size of the constant
uint16 const SETTINGS_RESERVED_LEN = ((62*1024) - sizeof(uint32) -
(sizeof(uint16) + // m_Len
sizeof(uint16) + // m_ConfigVersion
USER_ID_LEN +..
which ended up being 13800 in LabWindows CVI. Up to this point wverything was ok.
Then I also replaced the declarations of the error values which where of the sort
// Return error codes
/*
int const ERR_SUCCESS = 0;
int const ERR_INVALID_PARAMETER = -1;
int const ERR_OPERATION_NOT_SUPPORTED = -2;
by precompiler definitions:
#define ERR_SUCCESS = 0;
#define ERR_INVALID_PARAMETER = - 1;
#define ERR_OPERATION_NOT_SUPPORTED = -2;
These definitions may have been ok as they where but I thought that it will not hurt to do it this way.
When I tried to generate the import library using the header file with the modicications that I mentioned, I get a different error:
"Unble to generate DLL glue code. Error in header file "d:\ As5216.h" at line 363, clumn 1: sintax error; found 'string constant' expecting ';'
I checked to see if there was any semicolon left fromthe previous declarations, but I do not see any.
What could be the reason to thhis new error?.
Another question is , what is the DLL_API modifier mean?.
I appreciate any suggestions. Thanks for helping us already.
Regards,
Fundadero
and so on.
07-07-2010 11:48 PM
To understand the cause of that error we should beable to examine the file after your modifications. In any case, you must delete all semicolons at the end of each #define line.
Did you try to compile the file before changing the CONST to #define?
07-08-2010 01:32 AM
Hi Roberto,
No I did not try to compile the file. But i did not find extraneous semicolons. I have a header file and a dll file and i am trying to generate the import library to be able to call functions from a CVI program.
I attach the header file. Do you want me to attach the dll file?.
Thanks for your help.