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

ページ / 211
Chapter 3
Windows 95/NT Compiler/Linker Issues
©
 National Instruments Corporation
3-15
LabWindows/CVI Programmer Reference Manual
For a DLL, you also have to call 
CloseCVIRTE
 in 
DLLMain
. The code must include the 
following segment:
#include <cvirte.h>
int __stdcall DllMain (HINSTANCE hinstDLL, DWORD fdwReason, 
                       LPVOID pvReserved)
{
   if (fdwReason == DLL_PROCESS_ATTACH) 
      {
      if (InitCVIRTE (hinstDLL, 0, 0) == 0)
          return 0; /* out of memory */
      /* your other ATTACH code  */
      }
else if (fdwReason == DLL_PROCESS_DETACH) 
   {
   /* your other DETACH code */
   CloseCVIRTE (); 
   }
      return 1;
}
Note
It is harmless, but unnecessary, to call these functions when you link your 
executable in LabWindows/CVI for Windows 95/NT.
Watcom Stack Based Calling Convention
When you use the LabWindows/CVI libraries in the Watcom compiler, you must set the 
default calling convention to the 80486 Stack Based calling convention. In the command line 
compiler, this is the 
-4s
 option. In the Watcom IDE, you can set the default calling convention 
by using the Options»C Compiler Switches command. The option is in the Target Processor 
section of the Memory Model and Processor Switches section of the dialog box. If you do not 
set this option, the Watcom linker reports undefined references to the LabWindows/CVI 
run-time libraries.
Using Object and Library Files in External Compilers
When you use an external compiler to link a project that contains object or static library files 
created in LabWindows/CVI, keep several points in mind.
Default Library Directives
Most compilers insert default library directives in the object and library files they generate. 
A default library directive tells the linker to automatically include a named library in the link. 
Normally, the directive refers to the name of C library files. If no files in the link contain a 
00ProRef.book : 06chap03.fm  Page 15  Monday, March 9, 1998  3:23 PM