| _DLL_glbvar | Function (Macro Constructor)

dll.h

#define _DLL_glbvar(type,index) (*(_DLL_reference (type, index)))

Returns a dereferenced pointer to a global variable in a DLL.

_DLL_glbvar gets a void pointer to the location of the index-th exported symbol of the currently loaded DLL (using _DLL_entry), casts this pointer to a pointer of type type, and then dereferences it. As the constructed object is a dereferenced pointer, it is a valid lvalue, so it can be used as a global variable. This macro is usually used for accessing global variables exported by the DLL. For example, suppose that the DLL contains the following declarations in the DLL interface section (see DLL_INTERFACE):

    unsigned short foo;
    ...
    DLL_EXPORTS &foo

Then foo will get the index number 0. To 'import' this global variable from the DLL (assuming that the DLL is sucessfully loaded using LoadDLL), you should use the following definition:

    #define foo _DLL_glbvar (unsigned short, 0)

Then you can use foo just like a normal global variable. For example:

    printf ("%d", foo);
    foo = 50;

See also: _DLL_call, _DLL_call_attr, _DLL_reference