#EXPORT metastatement  

Purpose

Declare a Sub/Function to have the EXPORT attribute.

Syntax

#EXPORT SubFuncName [, SubFuncName...]

Remarks

#EXPORT allows you to add the EXPORT attribute to a Sub/Function defined elsewhere.   The EXPORT attribute can even be added to a Sub/Function in an SLL which was compiled separately.

The EXPORT descriptor identifies a Sub/Function which may be accessed between Dynamic Link Libraries (DLLs), and/or the main executable which links them.  If a procedure is not marked EXPORT, it is hidden from these other modules.  Generally speaking, it's best not to mark a Sub/Function in an SLL as EXPORT.  While it is syntactically acceptable, it may limit your future options when linking the SLL into host modules.  PowerBASIC recommends that you mark them as COMMON in the SLL, and add the EXPORT attribute in the host module.

It's easy to create an SLL which can be linked into an executable program or a dedicated DLL for the same purpose.  To add the EXPORT attribute to a linked Sub/Function, just add the word EXPORT to the DECLARE statement in the host module or add an #EXPORT metastatement.

Using this technique, your SLL can be linked directly into an application executable without publishing the Subs/Functions as EXPORT.  However, you can also link the same SLL into a DLL host module which adds the EXPORT attribute with #EXPORT.

For example, let's say you want to make a library which publishes the SUB named XXX.  You want to provide it in two forms, a linkable SLL and an industry standard DLL.  So, first just create the SLL:

#COMPILE SLL = "XXXLib.SLL"

 

SUB xxx() COMMON

  MSGBOX "Hello"

END SUB

Just compile it, and you're ready to link it into your application. But now you want to create a DLL, too, since it might be used with other applications.  It's just this easy:

#COMPILE DLL = "XXXLib.DLL"

 

#EXPORT xxx

#LINK "XXXLib.SLL"

That's all there is to it.  You now have an SLL and an equivalent DLL to do the job of the XXX procedure.

See also

#LINK, DECLARE