National Instruments 320685D-01 Drums User Manual


 
Chapter 3 Windows 95/NT Compiler/Linker Issues
LabWindows/CVI Programmer Reference Manual 3-24
©
National Instruments Corporation
You can solve these problems in several different ways:
You can avoid exporting variables from DLLs, and thereby eliminate the need to use
import qualifiers. For each variable you want to export, you can create functions to
get and set its value or a function to return a pointer to the variable. You do not have
to use import qualifiers for functions. This is the simplest approach and works in
LabWindows/CVI. However, it does not work if you use an export qualifier in a
function definition and you create the DLL with an external compiler that requires
the declaration to use the same qualifier.
You can create a separate include file for distribution with the DLL.
You can use a special macro that resolves to either an import or export qualifier
depending on a conditional compilation flag. In LabWindows/CVI you can set the flag
in your DLL project by using the Compiler Defines command in the Options menu of
the Project window.
Recommendations
To make creating a DLL as simple as possible, adhere to the following recommendations:
•Use the
DLLSTDCALL macro in the declaration and definition of all functions you want
to export. Do not export functions with a variable number of arguments.
Identify the symbols you want to export using the include file method. Do not use export
qualifiers. If you use an external compiler, use the
.def file method.
Do not export variables from the DLL. For each variable you want to export, create
functions to get and set its value or a function to return a pointer to the variable. Do not
use import qualifiers in the include file.
If you follow these recommendations, you reap the following benefits:
You can distribute with your DLL the same include file that you include in the source files
you use to make the DLL. This is especially useful when you create DLLs from
instrument drivers.
You can use the same source code to create the DLL in LabWindows/CVI and any of the
four compatible external compilers.
You can use your DLL in Microsoft Visual Basic or other non-C environments.
Automatic Inclusion of Type Library Resource for Visual Basic
The Create Dynamic Link Library command gives you the option to automatically create
a Type Library resource and include it in the DLL. When you use this option, Visual Basic
users can call the DLL without having to use a header file that contains
Declare statements
for the DLL functions. The command requires that you have a function panel file for
your DLL.
00ProRef.book : 06chap03.fm Page 24 Monday, March 9, 1998 3:23 PM