in PureBasic it's very laborious to write a cross platform application with using DLL's. Why? The reason is the separation of CallFunction()/CallFunctionFast() and CallCFunction()/CallCFunctionFast(). For example a wrapper for the FMOD-Library. For Windows-Version I must use "CallFunction()", for Linux I must use "CallCFunction()". So I must check the OS in every procedure. Very annoying:
Code: Select all
Procedure FMOD_FSOUND_Init(Sampling, Channels, Flags)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
ProcedureReturn CallFunction(#Library, "FSOUND_Init", Sampling, Channels, Flags)
CompilerElse
ProcedureReturn CallCFunction(#Library, "FSOUND_Init", Sampling, Channels, Flags)
CompilerEndIf
EndProcedure
Procedure FMOD_FSOUND_Sample_Load(SampleIndex, SourceFile$)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
ProcedureReturn CallFunction(#Library, "FSOUND_Sample_Load", SampleIndex, SourceFile$, 0, 0, 0)
CompilerElse
ProcedureReturn CallCFunction(#Library, "FSOUND_Sample_Load", SampleIndex, SourceFile$, 0, 0, 0)
CompilerEndIf
EndProcedure
....
Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
LibraryMode(#PB_Library_STDCALL)
CompilerElse
LibraryMode(#PB_Library_CDECL)
CompilerEndIf
Procedure FMOD_FSOUND_Init(Sampling, Channels, Flags)
ProcedureReturn CallFunction(#Library, "FSOUND_Init", Sampling, Channels, Flags)
EndProcedure
Procedure FMOD_FSOUND_Sample_Load(SampleIndex, SourceFile$)
ProcedureReturn CallFunction(#Library, "FSOUND_Sample_Load", SampleIndex, SourceFile$, 0, 0, 0)
EndProcedure
....
An other idea is for example to set the mode by loading: OpenLibrary(#Library, filename$, mode)
What do you think about it? Other ideas? In BlitzBasic, for example, the library mode (STDCALL/CDECL) was detected automatically...