The PB help says:
Quote:
Notes about creating DLL's:
- The declaration of arrays, lists or map with Dim, NewList or NewMap must always be done inside the procedure AttachProcess.
- Don't write program code outside procedures. The only exception is the declaration of variables or structures.
- DirectX initialization routines must not be written in the AttachProcess procedure.
If I follow these rules, that isn't allowed:
Code:
Procedure Test()
Protected NewList MyList.s()
...
EndProcedure
The list must be declared globally:
Code:
Procedure AttachProcess(Instance)
Global NewList MyList.s()
EndProcedure
Procedure Test()
... MyList() ...
EndProcedure
On Linux, the procedure "AttachProcess" is not performed automatically when the library opens.
This way is incorrect, because code exists outside procedures:
Code:
Procedure AttachProcess(Instance)
Global NewList MyList.s()
EndProcedure
CompilerIf #PB_Compiler_OS <> #PB_OS_Windows
AttachProcess(0)
CompilerEndIf
Procedure Test()
... MyList() ...
EndProcedure
It only remains this way:
Code:
OpenLibrary(0, "DLLPath")
CompilerIf #PB_Compiler_OS <> #PB_OS_Windows
CallFunction(0, "AttachProcess", 0)
CompilerEndIf
...
Is that all right? How is it correct?