CLIENT
Code: Select all
EnableExplicit
#PROTO_WITH_STRING = 1
Define a$
CompilerIf #PROTO_WITH_STRING = 1
If OpenLibrary(0, "lib.dll")
Prototype.s p_Proc1 (a$, b$) ; this will not work
Global Proc1.p_Proc1 = GetFunction(0, "Proc1")
EndIf
a$ = Proc1 ("hello", "fred") ; no way
CompilerElse
If OpenLibrary(0, "lib.dll")
Prototype.i p_Proc1 (a$, b$) ; this will work using PeekS
Global Proc1.p_Proc1 = GetFunction(0, "Proc1")
EndIf
a$ = PeekS(Proc1 ("hello", "fred")) ; why can't the compiler do this looking at the Prototype ?
CompilerEndIf
Debug "a$ = " + a$
DLL (lib.dll)
Code: Select all
Global Ret$
ProcedureDLL.s Proc1 (a$, b$)
Ret$ = a$ + " " + b$
ProcedureReturn Ret$
EndProcedure
See also (similar but using Imports) -> http://www.purebasic.fr/english/viewtop ... =3&t=40926
And this (DLL limitations and good practice to follow ?) -> http://www.purebasic.fr/english/viewtop ... 13&t=42537