LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SDK CVI compiler Warnings 64-bit

It seems I am finding CVI Compiler warnings when compiling 64 Bit applications with SDK. I don't get these warning errors when I compile the same applications for 32 Bit.

For example the CVI Compiler warning that I just found was found when I used SDK header file: "SetupAPI.h" with the typedef struct: SP_DEVINFO_DATA and SP_DEVICE_INTERFACE_DATA.

 

The warning message I got was when I compiled the statements with the SetupAPI.h file included:

 

SP_DEVINFO_DATA DeviceInfoData;

 

/* warning message */

DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);

 

// Warning: Conversion from 'unsigned __int64' to 'DWORD' might lose data.

 

/*warning message*/

SP_DEVICE_INTERFACE_DATA did = {sizeof(did)};

 

// Warning: Conversion from 'unsigned __int64' to 'DWORD' might lose data.


When I compile these statements in 32-Bit I don't get these errors.

Of course I can change the "SetupAPI.H" SDK Header supplied by NI but that defeats the whole purpose of why NI would distribute the header file in the first place.

0 Kudos
Message 1 of 4
(3,263 Views)

Hi Peter_Cooper,

 

The SetupAPI.H header file is part of the Windows DDK commonly used for USB related applications as discussed in the KB Missing Setupapi.h File When Loading a Third-Party DLL in LabWindows/CVI.

 

The reason this warning occurs is because the sizeof function returns a variable of a larger size on 64-bit systems versus 32-bit systems. A description of the different sizes of values and the warnings associated with them can be found in the KB Porting 32-bit Code to 64-bit Code.

 

If the size of the data types you are measuring is not very large then you should be able to explicitly caste the data types to avoid the warning, however make sure to review the Porting 32-bit Code to 64-bit Code article to avoid potential problems.


Milan
0 Kudos
Message 2 of 4
(3,245 Views)

OK - Milan -

I think you misunderstood what I was writing about.

If you look at the SetupAPI.h file that is supplied by NI SDK with CVI 2010 at line 700 with the following typedef  struct:

 

//
// Device information structure (references a device instance
// that is a member of a device information set)
//
typedef struct _SP_DEVINFO_DATA {
    DWORD cbSize;
    GUID  ClassGuid;
    DWORD DevInst;    // DEVINST handle
    ULONG_PTR Reserved;
} SP_DEVINFO_DATA, *PSP_DEVINFO_DATA;

 

The DWORD is defined as

"typedef unsigned long"

 in cvidef.h (CVI 2010) header file.

 

Yes I could change the SetupAPI.h inside the header file to change the type to be __int64 instead so that it works with 64 Bit. However, if other applications that are written for 32 bit will now be impacted if the SetupAPI.h is used with the __int64 data type DWORD.

 

So what NI should so everywhere where they define "DWORD" that is used in the SDK they should have a conditional compile to set the type to "typedef __int64" in CVI 64-bit applications and

"typedef unsigned long" in 32 Bit Applications.

0 Kudos
Message 3 of 4
(3,240 Views)

Hi Peter_Cooper,

 

Sorry for the confusion. I do not suggest that you modify the SetupAPI.h header file. Instead you can perform an explicit cast to the DWORD type  in your c file to prevent the warning from appearing during compilation for this application.

 

The SetupAPI.h header file included in the CVI SDK is a 3rd party file provided by Microsoft which acts as the Public header file for Windows NT Setup and Device Installer services Dll


Milan
0 Kudos
Message 4 of 4
(3,232 Views)