Chapter 11 415
Optimizing Agilent VEE Programs
Overview of Compiled Functions
Design Considerations in Using Compiled Functions
If you plan to use compiled functions in a VEE program, take the following
information into consideration:
n You can use any facilities available to the operating system including
math routines, instrument I/O, and so forth. However, you cannot access
any VEE internals from within the program to be linked.
n You need to provide error checking within your compiled function, since
VEE cannot trap errors in an external routine.
n You must de-allocate any memory you allocated in your external routine.
n When passing data to an external routine, make sure you configure the
Call object input terminals to the type and shape of data that the routine
requires.
n System I/O resources may become locked, so your external routine
should be able to handle this type of event.
n If your external routine accepts arrays, it must have a valid pointer for the
type of data it will examine. Also, the routine must check the size of the
array. If the routine changes the size, you need to pass the new size back
to the VEE program.
n The compiled function must use the
return() statement as its last
statement, not
exit(). If the compiled function exits, then so will VEE,
since a compiled function is linked to VEE.
n If you overwrite the bounds of an array, the result depends on the
language you are using. In Pascal, which performs bounds checking, a
run-time error will result, stopping VEE. In languages like C, where there
is no bounds checking, the result will be unpredictable, but may cause
intermittent data corruption or cause VEE to crash.