unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Mike Gran <spk121@yahoo.com>
To: Vivien Kraus <vivien@planete-kraus.eu>, guile-user@gnu.org
Subject: Re: Are char* and signed char* compatible (SCM_BYTEVECTOR_CONTENTS)?
Date: Fri, 26 Feb 2021 03:15:10 -0800	[thread overview]
Message-ID: <b17ebd6c9f1905f8f41f361fd11b051be70f9699.camel@yahoo.com> (raw)
In-Reply-To: <768f0a03350676677860ab874f79904a5acbe75b.camel@planete-kraus.eu>

On Fri, 2021-02-26 at 10:33 +0100, Vivien Kraus via General Guile
related discussions wrote:
> Hello,
> 
> I’m trying to use a bytevector from C.
> 
> 1. According to an example in the manual, SCM_BYTEVECTOR_CONTENTS can
> be assigned to a char*.
> 
> 2. Also from the manual, it is a signed char*.
> 
> 3. I've found this question online saying they are not compatible (
> https://stackoverflow.com/questions/12769500/why-is-char-not-compatible-with-signed-char-or-unsigned-char
> ).
> 
> As I understand it, at least one of the above 3 affirmations is
> incorrect. Could someone clarify this to me?

Depending on your compiler and OS, char is either signed char (-128 to
127) or unsigned char (0 to 255).  It is probably signed char.

You are free to cast the contents of a bytevector as signed char *,
unsigned char *, or char * (which is probably signed char).  It depends
on what you want.  When you use a  bytevector from within Guile, it
will appear as unsigned 8=bit integers. But from within guile you could
use bytevector-s8-ref if you wanted to pull a byte out as a signed 8-
bit integer.

-Mike





      reply	other threads:[~2021-02-26 11:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26  9:33 Are char* and signed char* compatible (SCM_BYTEVECTOR_CONTENTS)? Vivien Kraus via General Guile related discussions
2021-02-26 11:15 ` Mike Gran [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b17ebd6c9f1905f8f41f361fd11b051be70f9699.camel@yahoo.com \
    --to=spk121@yahoo.com \
    --cc=guile-user@gnu.org \
    --cc=vivien@planete-kraus.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).