Chapter 3 Windows95/NT Compiler/Linker Issues
©
National Instruments Corporation 3-23 LabWindows/CVI Programmer Reference Manual
macro to resolve differences among compilers and platforms. The following are examples of
using the DLLEXPORT macro:
int DLLEXPORT DLLSTDCALL MyFunc (int parm) {}
int DLLEXPORT myVar = 0;
If the type of your variable or function requires an asterisk (*) in the syntax, put the qualifier
after the asterisk, as in the following example:
char * DLLEXPORT myVar = NULL;
Note Borland C/C++ version 4.5x, requires that you place the qualifier before the
asterisk. In Borland C/C++ 5.0, you can place the qualifier on either side of the
asterisk.
When LabWindows/CVI creates a DLL, it exports all symbols for which export qualifiers
appear in either the definition or the declaration. If you use an export qualifier on the
definition and an import qualifier on the declaration, LabWindows/CVI exports the symbol.
The external compilers differ widely in their behavior on this point. Some require that the
declaration and definition agree.
Note If you include in your DLL project an object or library file that defines exported
symbols, LabWindows/CVI cannot correctly create import libraries for each of the
external compilers. This problem does not arise if you use only source code files
in your DLL project.
Marking Imported Symbols in Include File Distributed with DLL
If your DLL might be used in a C or C++ environment, you must distribute an include file
with your DLL. The include file must declare all the symbols the DLL exports. If any of these
symbols are variables, you must mark them with an import qualifier. Variable declarations
require import qualifiers so that the compiler can generate the correct code for accessing the
variables.
You can use import qualifiers on function declarations, b ut the y are not necessary. When you
use an import qualifier on a function declaration, external compilers can generate slightly
more efficient code for calling the function.
Using import qualifiers in the include file you distribute with your DLL can cause problems
if you use the same include file in the DLL source code:
If you mark variable declarations in the include file with import qualifiers and you use
the include file in a source file other than the one in which you define the variable,
LabWindows/CVI and the external compilers treat the variable as if it were imported
from another DLL and generate incorrect code as a result.
If you use export qualifiers in the definition of symbols and the include file contains
import qualifiers on the same symbols, some external compilers report an error.

00ProRef.book : 06chap03.fm Page 23 Monday, March 9, 1998 3:23 PM