National Instruments Drums 320685D-01 ユーザーズマニュアル

ページ / 211
Chapter 3
Windows 95/NT Compiler/Linker Issues
LabWindows/CVI Programmer Reference Manual
3-22
©
 National Instruments Corporation
project. You must use the _
_stdcall
 keyword in the declarations in the include file you 
distribute with the DLL.
Other platforms, such as UNIX or Windows 3.1 do not recognize the 
__stdcall
 keyword. 
If you work with source code that you might use on other platforms, you must use a macro in 
place of 
__stdcall
. The 
cvidef.h
 include file defines the 
DLLSTDCALL
 macro for this 
purpose.
The following are examples of using the 
DLLSTDCALL
 macro.
int DLLSTDCALL MyIntFunc (void);
char * DLLSTDCALL MyStringFunc (void);
Note
You cannot use the __
stdcall
 calling convention on functions with a variable 
number of arguments. Consequently, you cannot use such functions in Microsoft 
Visual Basic.
Exporting DLL Functions and Variables
When a program uses a DLL, it can access only the functions or variables that the DLL 
exports. The DLL can export only globally declared functions and variables. The DLL cannot 
export functions and variables you declare as 
static
.
If you create your DLL in LabWindows/CVI, you can indicate which functions and variables 
to export in two ways: the include file method and the qualifier method. 
Include File Method
You can use include files to identify symbols to export. The include files must contain the 
declarations of the symbols you want to export. The include files can contain nested 
#include
 statements, but the DLL does not export the declarations in the nested include 
files. In the Create Dynamic Link Library dialog box, you select from a list of all the include 
files in the project. 
The include file method does not work with other compilers. However, it is similar to the 
.def
 method that the other compilers use.
Export Qualifier Method
You can mark each function and variable you want to export with an export qualifier. 
Currently, not all compilers recognize the same export qualifier names. The most commonly 
used qualifier is 
__declspec(dllexport)
. Some also recognize 
__export
LabWindows/CVI recognizes both. The 
cvidef.h
 include file defines the 
DLLEXPORT
 
00ProRef.book : 06chap03.fm  Page 22  Monday, March 9, 1998  3:23 PM