Reference Manual

PureBasic syntax used

You can use arrays, linked lists, global/shared/protected variables, structures, interfaces, etc., and every function or feature PureBasic provides, as long as you use them inside your Procedure's and ProcedureDLL's. But you can, of course, make enumerations and interface, structure, global and procedure declarations outside. Any other code outside procedures will be ignored, except for DataSection's and the Data's, IncludeBinary's and labels inside them. IncludeFile is also allowable outside the procedure, of course, because the compiler processes it before creating the 'PureBasic.asm' file.

Be careful when using PureBasic string manipulation functions, like in the second example: if the program that uses your library doesn't make any string manipulation, it won't compile; Purebasic adds a special library, SystemBase.lib (in the PureBasic/Compilers/ folder) when string allocation is needed by the program, but not when it's needed by the included libraries.

I thought of including SystemBase.lib in all libraries that called string manipulation functions, but it's probably overkill, and most of the time that lib will be included twice if I do so.

So, my advice would be to avoid string manipulation in your code (use direct strings, or only memory addresses), unless you're sure that the programs using your library will manipulate strings. Anyway, Fred, the PureBasic's main coder, has told me this would not be a problem in future PureBasic versions.

IMPORTANT: PBCompiler.exe may crash if ProcedureDLL has incorrect case (i.e.: pRocEduRedll).

MORE IMPORTANT: Using the following prefixes for library or function names may induce TailBite to unexpected errors: "SYS_", "PB_", "_PB", "p_", "v_", "e_", "t_", "a_", "_S", "l_", "s_". I strongly recommend you to avoid using such prefixes, specially the first three.

Note on using STATIC keyword : The static keyword is not supported by tailbite. (The generated PureBasicStart routine is not evaluated.)
Please use a Global variable instead and initialize it in the Init function.

Note on string functions : Don't use exported string functions in the library !
This is not supported with PB versions >=4.20

ProcedureDLL$ proc(a) 
   ProcedureReturn Str(a) 

ProcedureDLL$ p(b) 
   ProcedureReturn proc(b) 

Instead use this :

; proc 
Procedure$ proc_private(a) ; private 
  ProcedureReturn Str(a) 
ProcedureDLL$ proc(a) ; exported 
  ProcedureReturn proc_private(a) 
ProcedureDLL$ p(b) 
  ProcedureReturn proc_private(b) ; use private version in your library 

Forum related thread :