From: Richard Jones <rich@annexia.org>
To: micha <micha-1@fantasymail.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] coding c++ enum type
Date: Sat, 24 Feb 2007 10:52:50 +0000 [thread overview]
Message-ID: <20070224105250.GA24014@furbychan.cocan.org> (raw)
In-Reply-To: <45E00103.9020809@fantasymail.de>
On Sat, Feb 24, 2007 at 10:10:27AM +0100, micha wrote:
>
> when interfacing to c, what is the preferred method to represent enums
> which are used as flags in c?
> I can choose between:
> 1. using a variant type and a list of those variants to represent the
> or-ed flags. Then I have to iterate over the list to calculate the
> combined flag value.
>
> 2. I can export global variables initialized with the real value of the
> flags and a function which combines (with "or") them together,
>
> Is one method better than the other?
I don't know about preferred, but most libraries seem to be using the
list approach (1). See for example to source to Unix.openfile:
http://camlcvs.inria.fr/cgi-bin/cvsweb/ocaml/otherlibs/unix/open.c?rev=1.8.2.3;content-type=text%2Fx-cvsweb-markup
(actually, convert_flag_list:
http://camlcvs.inria.fr/cgi-bin/cvsweb/ocaml/byterun/alloc.c?rev=1.29;content-type=text%2Fx-cvsweb-markup )
Rich.
--
Richard Jones
Red Hat UK Limited
next prev parent reply other threads:[~2007-02-24 10:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-24 9:10 micha
2007-02-24 10:52 ` Richard Jones [this message]
2007-02-24 21:33 ` [Caml-list] " Nathaniel Gray
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=20070224105250.GA24014@furbychan.cocan.org \
--to=rich@annexia.org \
--cc=caml-list@inria.fr \
--cc=micha-1@fantasymail.de \
/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