LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

.lib problems

Hi,
I am using an import library built using VC++ and an accompanying header file to try and talk to a USB Hid device.

I have copied the library file to the project folder and added it to the project and have included the header file in the source code.

When I build the project without actually calling any functions from the lilbrary file, i get abunch of errors like this

  "UsbHidApi.h"(128,11)   Warning: Empty declaration.
  "UsbHidApi.h"(128,11)   syntax error; found 'string constant' expecting ';'.
  "UsbHidApi.h"(128,11)   Unrecognized declaration.
  "UsbHidApi.h"(128,44)   Illegal return type 'array 2 of char'.
  "UsbHidApi.h"(130,11)   Warning: Empty declaration.
"UsbHidApi.h"(185,21)   Redeclaration of 'CUsbHidApi' previously declared at UsbHidApi.h:168.
  "UsbHidApi.h"(185,21)   Redeclaration of 'CUsbHidApi' previously declared at UsbHidApi.h:168.
  "UsbHidApi.h"(188,4)   Unrecognized declaration.
  "UsbHidApi.h"(188,21)   Redeclaration of 'CUsbHidApi' previously declared at UsbHidApi.h:185.
  "UsbHidApi.h"(200,41)   Redeclaration of 'GetList' previously declared at UsbHidApi.h:156.
  "UsbHidApi.h"(214,34)   Redeclaration of 'Open' previously declared at UsbHidApi.h:147.
_______________
I have the following lines in my test.c project source file

#include <cvirte.h>       
#include <userint.h>
#include "test.h"
#include "UsbHidApi.h"
____________
The header file
"UsbHidApi.h" looks somewhat like this
_____________________
#define USBHIDAPI_DLL_NAME    "UsbHidApi.dll"

#ifdef USBHIDAPI_EXPORTS
#define USBHIDAPI_API __declspec(dllexport)
#else
#define USBHIDAPI_API __declspec(dllimport)
#endif

   typedef struct {
    char         DeviceName[50];   // Device name
    char         Manufacturer[50]; // Manufacturer
    char         SerialNumber[20]; // Serial number
    unsigned int VendorID;         // Vendor ID
    unsigned int ProductID;        // Product ID
    int          InputReportLen;   // Length of HID input report (bytes)
    int          OutputReportLen;  // Length of HID output report (bytes)
    int          Interface;        // Interface 
    int          Collection;       // Collection
   } mdeviceList;

#pragma pack (push, 4)
   typedef struct {
    char         *DeviceName;   // Device name
    char         *Manufacturer; // Manufacturer
    char         *SerialNumber; // Serial number
    unsigned int VendorID;         // Vendor ID
    unsigned int ProductID;        // Product ID
    int          InputReportLen;   // Length of HID input report (bytes)
    int          OutputReportLen;  // Length of HID output report (bytes)
    int          Interface;        // Interface 
    int          Collection;       // Collection
   } mdeviceList2;
#pragma pack (pop,4)
   extern "C" int _stdcall SetInstance(int instance); 

   extern "C" int _stdcall GetLibVersion(char *buf);

   extern "C" void _stdcall ShowVersion(void);    
   extern "C" int _stdcall Open (unsigned int VendorID,    
                                   unsigned int ProductID,   
                                   char         *Manufacturer,
                                   char         *SerialNum,      
                                   char         *DeviceName,  
                                   int          bAsync);         

// This class is exported from the UsbHidApi.dll
class USBHIDAPI_API CUsbHidApi {
public:

   // Constructor
    CUsbHidApi(void);

   // Destructor
   ~CUsbHidApi(void);
   
  
   int GetList(unsigned int VendorID,   
               unsigned int ProductID,     
               char         *Manufacturer,
              char         *SerialNum,   
               char         *DeviceName, 
               mdeviceList  *pList,            
               int          nMaxDevices); 

     int Open (unsigned int VendorID, 
             unsigned int ProductID,   
             char         *Manufacturer,
             char         *SerialNum,     
             char         *DeviceName, 
             int          bAsync); 

My project settings are for __
stdcall

Any help you can provide would be greatly
appreciated.

Thanks,
Roy Deschain
Test Engineer
Maxim Integrated Products
0 Kudos
Message 1 of 4
(4,304 Views)
Hi Roy,

Unfortunately, your header file contains a definition for a class "CUsbHidApi". CVI, like all ANSI C compilers, does not support class declarations or usage. The only way around this would be to rewrite the library to not use classes to make it ANSI C compatible.

Regards,
0 Kudos
Message 2 of 4
(4,282 Views)
Thanks for the reply James.

I got the library and header file working. Just commented out the lines which were defined specifically for C++ and followed one of the App notes which deal with integrating VC++ code in CVI.

Roy Deschain
Test Engineer
Maxim Integrated Products
0 Kudos
Message 3 of 4
(4,279 Views)
Greetings Ni Discussion Forums:                                Robot Sad
 
  In all acatually, which I trust won't result with me being banned from this site, especially once you've read the reason for it...,  I'm not using the software
and/or hardware or any of the products form NI.   I'm no closer to being a programmer than I am to being the navigator of Space Shuttle Atlantis.
My reason for being here is to abstain from surfing throughout the pornographic & gambling sites.  I don't intend to contribute 'SPAM'.  I'm attempting
to matriculate through-out this site primarily to learn secondly to attain the rank required to start tagging.
  I find this thread interesting in that there was a question or dificulty posed and a counteraction given.  Good Work yet I'm sure you know that since
I think the one who responded promotes LabView products.  I found my way here through reading a thread on 'LAVA' searching for more info on
        "mdeviceList2"
One Love,One People,National Instruments:
        Chace [‡] Daggers                                Robot Sad
 
Chace[‡]Daggers
0 Kudos
Message 4 of 4
(4,045 Views)