Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: "Alexander V. Voinov" <avv@quasar.ipa.nw.ru>
Cc: caml <caml-list@inria.fr>
Subject: Re: [Caml-list] Data_custom_val(v)
Date: Fri, 20 Jul 2001 16:00:36 +0200	[thread overview]
Message-ID: <20010720160036.G9351@pauillac.inria.fr> (raw)
In-Reply-To: <3B510B1B.4552AFA1@quasar.ipa.nw.ru>; from avv@quasar.ipa.nw.ru on Sat, Jul 14, 2001 at 08:16:43PM -0700

> I forgot to mention that Data_custom_val(v) doesn't allow for
> assignments in C++, instead I have to use
> 
>     value blk = alloc_custom(...);
>     *(void **)&(Field(blk, 1)) = (void *)some_data;

Don't do that, because someday the data part of the custom block may
not be at offset 1.

What is wrong with

     value blk = alloc_custom(...);
     mytype * mydata = (mytype *) Data_custom_val(v);
     *mydata = <initial value>;

or, more concisely,
     *((mytype *) Data_custom_val(v)) = <initial value>;

Is it that evil C++ that don't let you do that?

- Xavier Leroy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


      reply	other threads:[~2001-07-20 14:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-15  3:16 Alexander V. Voinov
2001-07-20 14:00 ` Xavier Leroy [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

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

  git send-email \
    --in-reply-to=20010720160036.G9351@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=avv@quasar.ipa.nw.ru \
    --cc=caml-list@inria.fr \
    /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