From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-488.2 Driver Development Kit Version 1.0 - IBCHAT.C does not compile.

The file IBCHAT.C distributed with the NI488.2 DDK v1.0 is not compilable.
The 'testAbort' function is called many times with only 1 parameter when its prototype specifies 4 parameters, and the number of opening braces and closing braces is inconsistent, around line 2994.
0 Kudos
Message 1 of 2
(2,867 Views)
Hi Jordi,

It depends on the compiler used, gcc will compile the code.

The way the testAbort function is used is a not-too-elegant way of having variable number of arguments. Noticed that when one parameter is past to the function, the other parameters are not used. Any of these parameters will have whatever value is on the stack.

The compiler uses the prototype declaration, usually part of the header file, to check the parameters passed to the functions (types and number). Notice that the testAbort function is defined after it is used. This means that the compiler has no information of the function parameters and generates a call to the function assuming that the arguments are correct.

Calling the function is possible also because the C linker is
not type-safe. The linker will not check the number or type of arguments passed to the functions.

As I mentioned before, gcc will allow you to compile the code. Visual C++, for example, will not. In this case, just modify the function calls to have the four parameters. Just pass 0, these arguments are not used.

DiegoF
National Instruments.
0 Kudos
Message 2 of 2
(2,867 Views)