|Navigation: Language Reference > 5 - Declaration Attributes > Variable and Entity Attributes >====== DLL (set variable defined externally in .DLL) ======
DLL( [ flag ] )
|Declares a variable, FILE, QUEUE, GROUP, or CLASS defined externally in a .DLL.
|A numeric constant, equate, or Project system define which specifies the attribute as active or not. If the flag is zero, the attribute is not active, just as if it were not present. If the flag is any value other than zero, the attribute is active.
The DLL attribute specifies that the declaration (this may any variable declaration, or a FILE, QUEUE, GROUP, or CLASS structure) on which it is placed is defined in a .DLL. A declaration with DLL attribute must also have the EXTERNAL attribute. The DLL attribute is required for 32-bit applications because .DLLs are relocatable in a 32-bit flat address space, which requires one extra dereference by the compiler to address the variable. The DLL attribute is not valid on variables declared within FILE, QUEUE, CLASS, or GROUP structures.
The declarations in all libraries (or .EXEs) must be EXACTLY the same (with the appropriate addition of the EXTERNAL and DLL attributes). If they are not exactly the same, data corruption could occur. Any incompatibilities between libraries cannot be detected by the compiler or linker, therefore it is the programmer's responsibility to ensure that consistency is maintained.
When using EXTERNAL and DLL on declarations shared by .DLLs and .EXE, only one .DLL should define the variable, FILE, CLASS, or QUEUE without the EXTERNAL and DLL attributes. All the other .DLLs (and the .EXE) should declare the variable, FILE, CLASS, or QUEUE with the EXTERNAL and DLL attributes. This ensures that there is only one memory allocation for the variable, FILE, CLASS, or QUEUE and all the .DLLs and the .EXE will reference the same memory when referring to that variable, FILE, or QUEUE.
One suggested way of coding large systems using many .DLLs and/or .EXEs that share the same variables would have one .DLL containing the actual data definition that only contains FILE and global variable definitions that are shared among all (or most) of the .DLLs and .EXEs. This makes one central library in which the actual file definitions are maintained. This one central .DLL is linked into all .EXEs that use those common files. All other .DLLs and/or .EXEs in the system would declare the common variables with the EXTERNAL and DLL attributes.
There is a pre-defined flag used by the IDE Project System and the Application Generator.
|Used by the ABC template chain on all CLASS definitions to indicate that the CLASS is declared in an external .DLL. A project DEFINE is used to toggle the DLL mode.
TotalCount LONG,EXTERNAL,DLL(dll_mode) !A variable declared in an external .DLL
Cust FILE,PRE(Cus),EXTERNAL(''),DLL(1) !File defined in PROGRAM module of a .DLL
DLLQueue QUEUE,PRE(Que),EXTERNAL,DLL(1) !A queue declared in an external .DLL
EditEntryClass CLASS(EditClass),TYPE,MODULE('ABEIP.CLW'),LINK('ABEIP.CLW',| _ABCLinkMode_),DLL(_ABCDllMode_)