guile-user
[Top][All Lists]
Advanced

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

Re: Strings from C?


From: Dirk Herrmann
Subject: Re: Strings from C?
Date: Thu, 18 Oct 2001 20:24:26 +0200 (MEST)

On Tue, 16 Oct 2001, Robert A. Uhl wrote:

> I am writing an interface to various classes written in C; my project
> is located at <http://travtrack.sf.net/>.  I decided to use guile
> because it is such an exceedingly cool piece of work; the developers
> really seem to have done a good job.  What I find lacking is
> documentation.
> 
> Given that one already has a string, what is the proper way to return
> am SCM string?  I have read the data-rep document, and have been
> unenlightened--did I miss something?

In the newest guile (i. e. 1.5.4 or the CVS version) you should use either
  extern SCM scm_mem2string (const char *src, size_t len);
or
  extern SCM scm_str2string (const char *src);
where the second will do a strlen computation to figure out the length,
while in the first you can create strings with \0 characters.  Both
functions will create a copy of the characters.  That is, modifications to
your SCM string will not have any effect on the original C string.

Best regards
Dirk Herrmann




reply via email to

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