C functions with variable parm lists 
Author Message
 C functions with variable parm lists

How would you declare a Dylan C-ffi function to call, for example,
sprintf in FD 2.0?
Since sprintf has the signature
int sprintf( char *buffer, const char *format [, argument] ... ) in
which "argument"
has no type and can be variable in number, the C-ffi doesn't appear to
handle this case.
Is it possible?

TIA.

John Whittaker

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Tue, 29 Oct 2002 03:00:00 GMT  
 C functions with variable parm lists

Quote:
> How would you declare a Dylan C-ffi function to call, for example,
> sprintf in FD 2.0?
> Since sprintf has the signature
> int sprintf( char *buffer, const char *format [, argument] ... ) in
> which "argument"
> has no type and can be variable in number, the C-ffi doesn't appear to
> handle this case.
> Is it possible?

AFAIK there's no way to call a varargs function directly through the
C-FFI.  I looked up the comp.lang.c FAQ and the section (15) on
variable-length argument lists seems to suggest that, unless you have a
version of your function written specially to work with <stdarg.h> (e.g.,
vprintf) you're stuck.  There isn't any C version of Dylan's "apply"
apart from this.  See <http://www.faqs.org/faqs/C-faq/faq/>.

So maybe for printf (and scanf under "C9X", whatever that is) you can do
it -- otherwise, find a function which doesn't use varargs ;-)

Presenting a Dylan function to C as if it were a varargs function should
be easier, by writing a wrapper in the other direction, using the
<stdarg.h> stuff as one usually does.

HTH,
Hugh



Wed, 30 Oct 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing parm hex parm to STCKCONV

2. why no function(parm)^ in the Modula-2 language

3. How to get the list of imported variables/functions

4. How do I let a function accept a variable number of lists:

5. to CS: or not to CS: in F-PC assembler

6. please unscribe dinh@cs.ucla.edu from the scheme mailing list

7. Passing variables to user functions of Clipper functions

8. Trouble using variables for function names in function declarations

9. indirect function calls and variable variables

10. indirect function calls and variable variables

11. Trouble using variables for function names in function declarations

12. function while true - list function?

 

 
Powered by phpBB® Forum Software