[fpc-pascal] callback from c with varargs
Luca Olivetti
luca at ventoso.org
Sun Dec 20 16:06:04 CET 2020
El 20/12/20 a les 14:00, Jonas Maebe via fpc-pascal ha escrit:
> On 20/12/2020 13:01, Luca Olivetti via fpc-pascal wrote:
>> El 19/12/20 a les 23:15, Jonas Maebe via fpc-pascal ha escrit:
>>> It is indeed not possible to implement a function with C varargs in FPC.
>>
>> I was afraid that's the answer :-(
>>
>> as an ugly workaround, I wrote a c library that vsnprintf msg and args
>> to a buffer and then calls a pascal function with no varargs.
>>
>> It works but, as I said, it's ugly and I'd need to provide a .a for
>> every platform I plan to use.
>>
>> Is there a better/simpler way (apart from asking the library developers
>> to use a callback with no varargs)?
>
> No.
:-(
Oh, well, that's life.
Now I'm struggling to integrate my stub function under win32 (no problem
with linux/64).
The linker complains about
Error: Undefined symbol: _vsnprintf
Error: Undefined symbol: _ua_pascallog
the first it's probably because it's missing some library (which?) but
the second is defined in my program (and, as I said, it builds and works
fine under linux/64) as:
procedure ua_pascallog(logContext: Pointer; level: UA_LogLevel;
category: UA_LogCategory; msg: PAnsiChar);cdecl;export;
Any hint?
Bye
--
Luca
More information about the fpc-pascal
mailing list