Hi all,

My understanding is that it is not valid to write a comment to an
attribute.  However, the following code runs without error on
1.8.5-p1:

#include <hdf5.h>

int main()
{
    const hid_t f = H5Fcreate(
            "foo.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    H5Oset_comment(f, "file comment");

    hsize_t dims = 1;
    const hid_t s = H5Screate_simple(1, &dims, NULL);
    const hid_t a = H5Acreate2(
            f, "x", H5T_NATIVE_INT, s, H5P_DEFAULT, H5P_DEFAULT);
    H5Sclose(s);
    int x = 5;
    H5Awrite(a, H5T_NATIVE_INT, &x);
    H5Oset_comment(a, "attribute comment");
    H5Aclose(a);
    H5Fclose(f);

    return 0;
}

Running the compiled binary and examining the foo.h5 file it produces
with h5dump shows

HDF5 "foo.h5" {
GROUP "/" {
   COMMENT "attribute comment"
   ATTRIBUTE "x" {
      DATATYPE  H5T_STD_I32LE
      DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
      DATA {
      (0): 5
      }
   }
}
}

where it appears that setting the comment on an attribute overwrites
the file-level comment.

Two questions arise:

1) Am I incorrect in saying that an attribute cannot contain a comment?
2) Is HDF5 1.8.5-p1 failing to detect a usage error in my sample code?

Thanks,
Rhys

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to