National Instruments 320685D-01 Drums User Manual


 
Chapter 1 LabWindows/CVI Compiler
©
National Instruments Corporation 1-7 LabWindows/CVI Programmer Reference Manual
For example, the code
int x;
declares a 2-byte integer in a 16-bit compiler such as LabWindows for DOS. In contrast,
a 32-bit compiler such as LabWindows/CVI handles this code as a declaration of a 4-byte
integer. In most cases, this does not cause a problem and the conversion is transparent,
because functions that use 2-byte integers in LabWindows for DOS use 4-byte integers in
LabWindows/CVI. However, this conversion does cause a problem when a program performs
one of the following actions:
Passes an array of 16-bit integers to a GPIB, VXI, or Data Acquisition (DAQ) function
If you use a 32-bit
int array to receive a set of 16-bit integers from a device,
LabWindows/CVI packs two 16-bit values into each element of the 32-bit array. Any
attempt to access the array on an element-by-element basis does not work. Declare the
array as
short instead, and make sure any type specifiers that refer to it have the [b2]
modifier when you pass them as an argument to a Formatting and I/O Library function.
•Uses an
int variable in a way that requires it to be a 2-byte integer
For example, if you pass an
int argument by address to a function in the Formatting and
I/O Library, such as a
Scan source or a Scan/Fmt target, and it matches a %d[b2] or
%i[b2] specifier, it does not work correctly. Remove the [b2] modifier, or declare the
variable as
short.
Conversely, if you pass a
short argument by address and it matches a %d or %i specifier
without the
[b2] modifier, it does not work correctly. Add the [b2] modifier.
Note The default for %d is 2 bytes on a 16-bit compiler and 4 bytes on a 32-bit compiler.
In the same way, the default for
int is 2 bytes on a 16-bit compiler, and 4 bytes on
a 32-bit compiler. This is why you do not have to make any modifications if the
specifier for a variable of type
int is %d without the b
n
modifier.
All pointers are 32-bit offsets. LabWindows/CVI does not use the
far pointers that have both
a segment selector and an offset, except in 16-bit Windows DLLs under Windows 3.1.
LabWindows/CVI for Windows 3.1 calls 16-bit DLLs through a special interface
LabWindows/CVI generates from the header file for the DLL. For more information, refer to
the Using 32-Bit Watcom Compiled Modules under Windows 3.1 and 16-Bit Windows DLLs
sections in Chapter 4, Windows 3.1 Compiler/Linker Issues.
00ProRef.book : 06chap01.fm Page 7 Monday, March 9, 1998 3:23 PM