Is the string a (1) fixed-length or (2) variable-length string?
(What does h5dump say? Or programmatically via "htri_t H5Tis_variable_str( 
hid_t dtype_id )"...)
Your code should work fine for (2) and a scalar attribute, but won't work with 
(1).
You'd have to allocate the buffer for the string(s) in (1) yourself.

G.

-----Original Message-----
From: Hdf-forum [mailto:[email protected]] On Behalf Of 
[email protected]
Sent: Thursday, July 23, 2015 11:55 AM
To: HDF Users Discussion List
Subject: [Hdf-forum] Weird H5Aread() error in HDF5 files - possibly a bug

Dear pros:

So a colleague of mine created an HDF5 for testing purposes using Labview, and 
I used my C++ program to read attributes from it, and that worked with the 
attached function with no problem.

Now I created my own HDF5 files with exactly the same structure, but with the 
difference that I'm using non-compound types. The attribute names are exactly 
the same. So I started my program and loaded my new files exactly like I do 
with the other files I got from my colleague, and got a crash. I pursued the 
issue with a debugger and found the situation attached in the image. It's a 
very weird situation that I can't understand. On the right, you'll find that 
all values are positive and read return is zero (so no error), and yet the 
assignment operator is throwing an error and the variable str, which is char*, 
is not accessible.

How could this happen? I could provide any additional information you require.

Thank you for any help you provide.

All the best,
Samer

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

Reply via email to