hdf5
hdf5 copied to clipboard
DataType: decide what type should be the arg of SetSize (for 32b platforms)
details:
- https://github.com/gonum/hdf5/pull/10#discussion_r132589035
In C
, H5Tset_size
takes a size_t
as argument to set the total size of the DataType
.
This was translated into DataType.SetSize(sz uint)
.
This wasn't taking into account the special value -1
that is used to make a DataType
of variable size.
we could settle for Go's int
but that would be wrong for 32b platforms.
perhaps use an explicit int64
?
I think int
is correct here. As mentioned in an afterthought comment, Go int
and C size_t
are likely to be the same size (not in NaCl, and certainly not guaranteed). I don't think we can guarantee that we are going to do the correct thing. We can however guarantee that we won't do the wrong thing. Because of the fact that we are depending on CGO, we know that we won't be running on NaCl, but we can also have an init function that ensures that unsafe.Sizeof(int(0)) == C.sizeof(size_t)
and panics otherwise. There are probably other sanity checks that would be worth considering here too.