[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Xavier Leroy <Xavier.Leroy@i...> |
| Subject: | Re: [Caml-list] Data_custom_val(v) |
> 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