Writing Nested Structure to HDF File in C

Hello Everyone,

I have to write following Structure to HDF File.
Ex:
typedef struct
{
int a;
int b;
Point c; // Point is a structure
} some_struct_name;

typedef struct
{
float x;
float y;
} Point;

I have created Compound datatype for the main structure as shown below
s_some_struct_name_tid = H5Tcreate(H5T_COMPOUND, sizeof(some_struct_name));

But I have to create Compound Datatype for the nested structure i.e., Point using H5Tinsert in order to write some_struct_name data to HDF File. Again declaring all the nested structures would be hectic.

Is there any way to write Nested Structures without redeclaring again using Compound Datatype?

Thanks in advance.

If C++ is an options for you then check out H5CPP which comes with LLVM based reflection for arbitrary deep POD dataypes. The header only library combined with compile time reflection makes the procedure automatic.

You could have the data-IO in c++ then link against it from C, just make sure you are exporting or demangling the C++ functions. In my projects I prefer C exports.

best steve