[Top][All Lists]

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

Re: SCM to C string

From: Rob Browning
Subject: Re: SCM to C string
Date: Fri, 21 Jun 2002 10:22:51 -0500
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-pc-linux-gnu)

Viktor Pavlenko <address@hidden> writes:

> I hurried with the reply... It _is_ described in the `Guile Reference
> Manual' by Mark Galassi but it's not in libguile/*.h headers. It's not
> in a snapshot version either. Neither I can find others like
> scm_c_symbol2str or scm_symbol2str (I'm trying to use scm_ functions
> you see).

Functions are being added to the scm_ interface as we prepare to
eventually deprecate the gh_ interface, so those functions may exist
in 1.5.X or CVS HEAD, but not in your version (1.4.X?).

> Please advise how to deal with this mess^h^h^h^hpuzzle.

Well, for now, you can use the equivalent gh_ functions if you're
running 1.4.X, and instead of scm_object_to_string, you could use

Something like the following perhaps (though you may need to translate
some of the scm_ functions to their equivalent gh_ functions).  You
may also need better error checking:

  char *
  objtostr (SCM obj)
    char *result;
    size_t length;

    SCM fmt = scm_makfrom0str("~S");
    SCM scmstr = scm_simple_format(SCM_BOOL_F, fmt, SCM_LIST_1(obj));
    length = SCM_STRING_LENGTH(scmstr);
    result = malloc(length + 1);
    if (!result) die...
    memcpy (result, SCM_STRING_CHARS (scmstr), length)
    result[length] = '\0';
    return result;

Rob Browning
rlb,, and
GPG=1C58 8B2C FB5E 3F64 EA5C  64AE 78FE E5FE F0CB A0AD

reply via email to

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