I'm using this code on Windows to import and test vsprintf (and vsnprintf):
Code: Select all
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
ImportC "user32.lib"
vsprintf.i( *buffer.i, format.p-ascii, *argptr )
_vsnprintf.i( *buffer.i, count.i, format.p-ascii, *argptr )
CompilerCase #PB_OS_Linux
ImportC ""
vsprintf.i( *buffer.i, format.p-ascii, *argptr )
vsnprintf.i( *buffer.i, count.i, format.p-ascii, *argptr )
CompilerCase #PB_OS_MacOS
ImportC ""
vsprintf.i( *buffer.i, format.p-ascii, *argptr )
vsnprintf.i( *buffer.i, count.i, format.p-ascii, *argptr )
CompilerEndSelect
EndImport
Define buffer.s = Space(1024)
Define value.l = 23
Debug vsprintf( @buffer, "Hi I'm %ld years old", @value )
Debug buffer
"[ERROR] Invalid Memory Access"
on the line:
Debug vsprintf( @buffer, "Hi I'm %ld years old", @value )
Any idea why this would happen on Linux/Mac and not on Windows ?
I don't have a linker error so I suppose the vsprintf function is properly imported ?