(C++) inserting ArrayType into a CompType

Dear list users,

can anyone help me with the following predicament? I want to create a compound datatype that contains an array. However, apparently the size is not what I expect and thus exceeds the dataspace.

Additional info: I use the C++ wrappers that come with HDF5 version 1.8.4.

Here's the error:

HDF5-DIAG: Error detected in HDF5 (1.8.4) thread 3070088912:
   #000: ../../../src/H5Tcompound.c line 374 in H5Tinsert(): unable to insert member
     major: Datatype
     minor: Unable to insert object
   #001: ../../../src/H5Tcompound.c line 466 in H5T_insert(): member extends past end of compound type
     major: Datatype
     minor: Unable to insert object
terminate called after throwing an instance of 'H5::DataTypeIException'

And here's the code I try to run:

// std
#include <cstdlib>
#include <iostream>

// hdf5
#include "H5Cpp.h"

/*

···

*
  */
int main(int argc, char** argv) {
     using std::cout;
     using std::endl;
     size_t size(100);
     H5::CompType network_type(size);
     H5std_string member_name("matrix");
     size_t offset(0);
     hsize_t* dimensions = new hsize_t[1];
     dimensions[0] = size;
     H5::ArrayType links(H5::PredType::NATIVE_HBOOL, 1, dimensions);
     cout << sizeof(H5::ArrayType) << endl;
     network_type.insertMember(member_name, offset, links);
     return (EXIT_SUCCESS);
}

TIA,
Moritz

It is possible that NATIVE_HBOOL is internally stored in a way (e.: int) that
results in size > 100 for your array (for int, size==400 on a 32-bit
machine). Your sizeof() call may not provide the correct amount of memory for
your actual array - only for the instance of the ArrayType class
that "represents" the storage you want.

-- Manoj

···

On Tuesday 31 August 2010 09:43:26 am Moritz Beber wrote:

Dear list users,

can anyone help me with the following predicament? I want to create a
compound datatype that contains an array. However, apparently the size
is not what I expect and thus exceeds the dataspace.

Additional info: I use the C++ wrappers that come with HDF5 version 1.8.4.

Here's the error:

HDF5-DIAG: Error detected in HDF5 (1.8.4) thread 3070088912:
   #000: ../../../src/H5Tcompound.c line 374 in H5Tinsert(): unable to
insert member
     major: Datatype
     minor: Unable to insert object
   #001: ../../../src/H5Tcompound.c line 466 in H5T_insert(): member
extends past end of compound type
     major: Datatype
     minor: Unable to insert object
terminate called after throwing an instance of 'H5::DataTypeIException'

And here's the code I try to run:

// std
#include <cstdlib>
#include <iostream>

// hdf5
#include "H5Cpp.h"

/*
  *
  */
int main(int argc, char** argv) {
     using std::cout;
     using std::endl;
     size_t size(100);
     H5::CompType network_type(size);
     H5std_string member_name("matrix");
     size_t offset(0);
     hsize_t* dimensions = new hsize_t[1];
     dimensions[0] = size;
     H5::ArrayType links(H5::PredType::NATIVE_HBOOL, 1, dimensions);
     cout << sizeof(H5::ArrayType) << endl;
     network_type.insertMember(member_name, offset, links);
     return (EXIT_SUCCESS);
}

TIA,
Moritz