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.



我可以使用一个复数类型作为一个labview DLL函数的返回值?



主要软件:
主要软件版本: 1.0
主要软件修正版本: N/A
次要软件: N/A

问题: 我在尝试使用labview的应用程序生成器创建一个DLL。其中一个VI的输出是双精度的复数。然而,当我在应用程序生成器中,尝试将函数的返回值设置成 cmplx128时,我遇到了一个错误。

解答:

当你将应用程序生成器中的一个函数的返回值设置成双精度复数(cmplx128),单精度复数(cmplx64),或者是扩展复数(cmplxExt)的数据类型,Labview会生成下列错误:

Error -2147221480 occurred at Building DLL stub.
This can be caused by illegal function or parameter names. Please verify your names are legal C identifiers and do not conflict with LabVIEW headers

这是Labview应用陈谷生成器的一个局限。你不能使用一个复数作为一个函数的返回值。然而,你可以通过把复数作为一个函数的参数来传递一个复数,然后使用它作为一个输出。请观察下列函数原型:

Invalid Prototype Valid Prototype
cmplxExt FunctionName(<parameters>) <return value> FunctionName(cmplxExt *parameter)
cmplx64 FunctionName(<parameters>) <return value> FunctionName(cmplx64 *parameter)
cmplx128 FunctionName(<parameters>) <return value> FunctionName(cmplx128 *parameter)


C:\Program Files\National Instruments\LabVIEW 7.1\cintools 文件夹下的extcode.h 头文件定义了cmplxExt, cmplx64, and cmplx128.

例如:

typedef struct {
float64 re, im;
} cmplx128;

这样,你可以在C/C++代码中使用通过labview 应用程序生成器或extcode.h 产生的 cmplx128 数据类型。你可以通过labview应用程序生成器的帮助文档和下方相关的链接来获得更多的信息。

 



相关链接: Developer Zone Tutorial: Building DLLs in LabVIEW 6.x or later
Developer Zone Tutorial: Calling a DLL from Microsoft Visual C++ that Was Generated by LabVIEW 6i
Developer Zone Tutorial: Calling a DLL from Microsoft Visual Basic That Was Generated By LabVIEW 6i


附件:





报告日期: 09/14/2004
最近更新: 06/29/2014
文档编号: 3DD8M2S9