guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: accessing a printf-like function from scheme


From: Tomas Zerolo
Subject: Re: accessing a printf-like function from scheme
Date: Tue, 25 Apr 2006 16:00:56 +0200
User-agent: Mutt/1.5.9i

On Tue, Apr 25, 2006 at 08:44:55AM -0400, Dan McMahill wrote:
> 
> Hello,
> 
> I'm trying to provide scheme access to a C function which has the same 
> interface a printf(). [...]

> SCM g_funcs_log(SCM s_num_list)
> {
>   SCM s_element;
>   int length;
>   int i;
> 
>   /* Check that the input is a list */
>   SCM_ASSERT (SCM_NFALSEP (scm_list_p (s_num_list)),
>             s_num_list,
>             SCM_ARG1,
>             "gschem-log");
>   length = scm_num2int(scm_length(s_num_list), 0, "g_funcs_log()");
> 
>   if (length == 0)
>      return SCM_BOOL_T;
> 
>   /* how to actully feed the data to s_log_message which
>    * has a printf-like interface
>    */
>   s_log_message ("Hi there.  Length = %d\n", length);
> 
>   return SCM_BOOL_T;
> }

I fear there is no portable way for this...

> If it would be easier I can also write a
> 
> void s_log_messagev (const char * restrict format, va_list ap);
> 
> to complement the
> 
> void s_log_message(const char * restrict format, ...);
> 
> I tried to find some sort of scm_list2_c_va_list() but haven't found it yet.
> 
> Any suggestions?

I'm not aware of a portable way of putting together a va_list (just of
taking it apart). And I wouldn't expect to see one -- C compilers do a
lot of obscure stuff to optimize parameter passing.

Maybe your function needs another interface (e.g. an array of params)?

Regards
-- tomás

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]