Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Labview Code Interface Reference Manual.pdf
Скачиваний:
34
Добавлен:
29.05.2015
Размер:
1.13 Mб
Скачать

Chapter 4 External Subroutines

instead of CIN. See the Steps for Creating a CIN section of Chapter 1, CIN Overview, for a discussion of the makefile contents.

Solaris 1.x, Solaris 2.x, and HP-UX

Unbundled Sun C Compiler and HP-UX C/ANSI C Compiler

The lvmkmf command for a CIN that calls an external subroutine is the same as described in the Steps for Creating a CIN section of Chapter 1, CIN Overview, except you use the -t option with the type LVSB to indicate that you are creating a LabVIEW subroutine instead of a CIN.

For example, if you want to create an external subroutine called find, you could use the following command:

lvmkmf -t LVSB find

This command creates a makefile that you could use to create the external subroutine.

Calling Code

You call external subroutines the same way that you call standard C subroutines. LabVIEW modifies the code at load time to ensure that the calling code passes control to the subroutine correctly.

When you call the external subroutine, do not use the function name LVSBMain to call the function. Instead, use the name you gave the external subroutine. If you created an external subroutine called fact.lsb, which in turn contained an LVSBMain() subroutine, for example, you should call the function as though it were named fact(). The argument list and return type should be the same as the argument and return type for the LVSBMain() subroutine.

You should also create a prototype for the function. This prototype should have the keyword extern so that the compiler will compile the CIN, even though the subroutine is not present.

When you create the makefile for the CIN, you identify the names of the external subroutines that the CIN calls. The LabVIEW makefile embeds information in your code that LabVIEW uses to determine that your code calls external subroutines. When you load external code that references external subroutines into a VI, LabVIEW searches for the

LabVIEW Code Interface Reference Manual

4-4

© National Instruments Corporation

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]