Can not get the number of attributes attached to root group

Hi, all:

     When I am trying to display the content of a .H5 files, I can not find a way to retrieve the number of attributes that are attached to the root group(or say file). In the following code, m_hdfID is the file ID when I open the .H5 file.
    int nAtts = H5Aget_num_attrs(m_hdfID); //==> nAtts is -1, means error occurs when trying to execute this function
    
    and if I use:
    int nAtts = H5Fget_obj_count(m_hdfID, H5F_OBJ_ATTR); //==> it return 0, which is not correct.

     Anything I did wrong or any solution for this problem? Thanks.
     Currently I have to loop all attribute using H5Aopen_idx(m_hdfID, iAttr), starting from iAttr = 0 to when H5Aopen_idx return minus value. Attached is the .H5 file I use for this testing code, it can be display in HDFView and HDF Explorer correctly.

hdf5data.h5 (37.5 KB)

···

--

Try
gid = H5Gopen(m_hdfID, "/"); /* the root group */
nAtts = H5Aget_num_attrs(gid);

ĺÈçÑ© wrote:

···

Hi, all:
When I am trying to display the content of a .H5 files, I can not find a way to retrieve the number of attributes that are attached to the root group(or say file). In the following code, m_hdfID is the file ID when I open the .H5 file.
int nAtts = H5Aget_num_attrs(m_hdfID); //==> nAtts is -1, means error occurs when trying to execute this function
and if I use:
int nAtts = H5Fget_obj_count(m_hdfID, H5F_OBJ_ATTR); //==> it return 0, which is not correct.
Anything I did wrong or any solution for this problem? Thanks.
Currently I have to loop all attribute using H5Aopen_idx(m_hdfID, iAttr), starting from iAttr = 0 to when H5Aopen_idx return minus value. Attached is the .H5 file I use for this testing code, it can be display in HDFView and HDF Explorer correctly.

--

------------------------------------------------------------------------
¿´Â½´¨ÑîÃÝÐÂƬ¡¶ÇÙÆåÊé»­¡·£¬Æ·ÍøÒ×3D¹úÔÏÍøÓΡ¶ÌìÏ·¡¡· <http://allyes.nie.163.com/main/adfclick?db=afanie&bid=1260,614,23&cid=148,4,1&sid=1357&show=ignore&url=http://tx2.163.com/fab.html>

------------------------------------------------------------------------

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