This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Accessing smob data


On Sun, 9 Apr 2000, Neil Jerram wrote:

> In many cases, a smob's "data" is a pointer to an
> application-allocated struct.  Previously (i.e. about 2 weeks ago
> CVS), such data could be accessed without a cast, viz.
> 
>       mystruct_t * dat = SCM_SMOB_DATA (s);
> 
> In current CVS, this generates a compile warning (integer to pointer
> conversion).  To avoid the warning, a cast is required, viz.
> 
>       mystruct_t * dat = (mystruct *) SCM_SMOB_DATA (s);
> 
> Two questions:
> 
> (1) Was this change an intentional side-effect of recent changes?

Yes.

> (2) Is SCM_SMOB_DATA the recommended way to extract a struct pointer
>     from a smob SCM value?

Actually, SCM_SMOB_DATA is the recommended way to extract arbitrary data
from a smob SCM value, not only to extract struct pointers.  Thus, it was
decided that SCM_SMOB_DATA should return a value of type scm_bits_t, which
is guile's type for any kind of raw data that can be stored in scheme
cells.  Two weeks ago (about), SCM_SMOB_DATA returned a value of type SCM,
which at that time was of type void*.

A first attempt at explaining the relationship between scm_bits_t and SCM
can be found in the file api.txt in the doc directory of the current cvs.

Best regards
Dirk Herrmann


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]