Crossplatform DLL with string parameters
Posted: Tue Mar 18, 2025 3:22 pm
Let's say i want to build a crossplatform dll with a function that accepts a string as a parameter.
The dll will be called from another language like C or objective-c for example.
Wich kind of string expects PB on the three paltforms?,
Passing this will work?
LPWSTR windows
const char* linux
const char* macos
For a dll like this, declaring a as s converts the string to a PB string?
Or do i need to do something like:
The dll will be called from another language like C or objective-c for example.
Wich kind of string expects PB on the three paltforms?,
Passing this will work?
LPWSTR windows
const char* linux
const char* macos
For a dll like this, declaring a as s converts the string to a PB string?
Code: Select all
ProcedureDLL test(a.s)
MessageRequester("Hello", a)
EndProcedure
Code: Select all
Procedure.s GetString(a.i)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
ProcedureReturn PeekS(a)
CompilerElseIf #PB_Compiler_OS = #PB_OS_Linux
ProcedureReturn PeekS(a, -1, #PB_UTF8)
CompilerElseIf #PB_Compiler_OS = #PB_OS_MacOS
ProcedureReturn PeekS(a, -1, #PB_UTF8)
CompilerEndIf
EndProcedure
ProcedureDLL test(a.i)
MessageRequester("Hello", GetString(a))
EndProcedure