[fpc-devel]fpgtk problem

KJK::Hyperion noog at libero.it
Sat Apr 5 17:44:44 CEST 2003

At 11.36 05/04/2003, you wrote:
>We talked internally about adding support for va_start, va_end and the 
>va_list type. But that wouldn't solve the problem for fpgtk since those 
>functions don't get a va_list.

well, TVarArgs (better name - TVAList should correspond to va_list) is just 
how it would appear to a Pascal program. What I meant was this:

function printf(fmt: PChar; args: TVarArgs = []); cdecl; external;

and you call it as:

printf('%s() failed: %d'#0A, ['blah', errno]);

The compiler treats the TVarArgs parameter specially, as a hint to 
translate the open array constructor into a list of arguments to be pushed 
on the stack. I agree that this sucks, and that supporting the implicit 
conversion of an array of TVarRec into a TVarArgs would suck even more, but 
it's an idea

>The problem with the fpgtk code is that it were macro's in C.


>And there is no possibility to have an exact function equivalent for it 
>except support also macro's

I suggest you to have a look at the C++ library Boost, and in particular at 
its "bind" template. It allows you to statically create function objects 
that, at runtime, call the function they're "bound" to, with parameters 
specified at compile time. I know FreePascal is far from that, but it's a 
cool concept

More information about the fpc-devel mailing list