Binh-Minh, I made it work. Being a novice HDF5 user, I did not know that I had to use H5Tenum_insert to define the enum datatype. Now everything works. Thanks a lot for your help!!! Yury,
On Wed, Jul 24, 2013 at 4:19 PM, Binh-Minh Ribler <[email protected]>wrote: > Hi Yury, > > Methods like getInMemDataSize(), getStorageSize(), etc. were what I > meant. > I'll keep an eye out for your message with an excerpt of the data file. > > Thanks, > Binh-Minh > ------------------------------ > *From:* Hdf-forum <[email protected]> on behalf of > Yury Girshovich <[email protected]> > *Sent:* Wednesday, July 24, 2013 3:34 PM > > *To:* HDF Users Discussion List > *Subject:* Re: [Hdf-forum] Reading enum bool attribute > > Hi Binh-Minh, > Thank you very much. I need to ask the owner permission first for > sharing the file. Perhaps they can create > a very small file just to display the problem. > Let me try to separate the code meanwhile, which may take a bit. I'll > email it to you with the data asap. > > I did not use an HDF5 method to find the attribute data type. Are there > any? I know the data type from the HDF5 viewer. > Here is the relevant portion of my code: > The disassembly is attached. > > . //is_hollow is enum with members {false, true} and value > size 1 > //bool h, h1, h2; > > size_t sz1 = attr.getInMemDataSize(); //=1 > size_t sz2 = attr.getStorageSize(); //=1 > printf("sz1 %d; sz2 %d, szbool %d\n", sz1, sz2, > sizeof(bool)); //sz1 1, sz2 1, szbool 1 > > //the sizes coincide, but each one of those calls crashes. > //int i1 = 0; > //attr.read(PredType::NATIVE_INT, &i1); > //printf("i1 = %d\n", i1); > char c1 = 0; > attr.read(PredType::NATIVE_CHAR, &c1); > > // attr.read(PredType::NATIVE_B8, &BB); > // attr.read(boolenumtype, &BB); > // attr.read(PredType::NATIVE_B8, &h); > // attr.read(PredType::NATIVE_UINT8, &h1); > // attr.read(PredType::NATIVE_UCHAR, &h2); > // printf("is_hollow %d %d %d\n", h, h1, h2); > } > > The error message is: > No source available for "raise() at 0x3d66835ba5" > The code crashed with all the versions of attribure datatypes. > > Thanks again, > Yury > > On Wed, Jul 24, 2013 at 3:02 PM, Binh-Minh Ribler > <[email protected]>wrote: > >> Hi Yury, >> >> Is there any chance I can have a copy of the file and that part of your >> code, from opening the file, perhaps? I want to repeat the exact steps. >> If not, please send me the errors. >> >> Binh-Minh >> ------------------------------ >> *From:* Hdf-forum <[email protected]> on behalf of >> Yury Girshovich <[email protected]> >> *Sent:* Wednesday, July 24, 2013 2:35 PM >> >> *To:* HDF Users Discussion List >> *Subject:* Re: [Hdf-forum] Reading enum bool attribute >> >> Scott, >> I agree about the enum size. It was the returned value of the call to >> attr.getInMemDataSize(). Sorry for the misinformation. >> >> The call to: >> >> int i; >> attr.read(PredType::NATIVE_INT, &i) >> >> causes a crash. That is not surprising because of the size discrepancy. >> But I also tried to use all kinds of 8bit creatures, >> like char, uchar, bool, replacing NATIVE_INT by NATIVE_CHAR, etc., but >> they all ended up with a crash. >> >> Thanks, >> Yury >> >> >> >> On Wed, Jul 24, 2013 at 1:57 PM, Mitchell, Scott - IS < >> [email protected]> wrote: >> >>> I don’t think enums are stored as 1byte. You can check with >>> H5T.getsize. >>> >>> >>> >>> What happens if you try your read with *attr_type* as a NATIVE_INT and*i >>> * as an int? Then cast it to bb. >>> >>> >>> >>> >>> >>> Scott >>> >>> >>> >>> *From:* Hdf-forum [mailto:[email protected]] *On >>> Behalf Of *Yury Girshovich >>> >>> *Sent:* Wednesday, July 24, 2013 1:04 PM >>> *To:* [email protected] >>> *Subject:* [Hdf-forum] Reading enum bool attribute >>> >>> >>> >>> I am trying to read an attribute defined as >>> >>> >>> >>> typedef enum {bbo=false, bb1=true} bb; >>> >>> >>> >>> as >>> >>> >>> >>> bb i; >>> >>> attr.read(attr_type, &i); >>> >>> The size of the attribute value is 1 byte. >>> >>> >>> >>> For attr_type I tried all kinds of 8 bit predicate types (as one advice >>> suggested use int, and then interpret your data), >>> >>> bur no matter what I do the code crashes. >>> >>> The value is inserted in a different code using Python, so I can get no >>> help from there. >>> >>> How should I define the predicate type then? >>> >>> Thanks >>> >>> >>> >>> ------------------------------ >>> >>> This e-mail and any files transmitted with it may be proprietary and are >>> intended solely for the use of the individual or entity to whom they are >>> addressed. If you have received this e-mail in error please notify the >>> sender. Please note that any views or opinions presented in this e-mail are >>> solely those of the author and do not necessarily represent those of Exelis >>> Inc. The recipient should check this e-mail and any attachments for the >>> presence of viruses. Exelis Inc. accepts no liability for any damage caused >>> by any virus transmitted by this e-mail. >>> >>> _______________________________________________ >>> Hdf-forum is for HDF software users discussion. >>> [email protected] >>> >>> http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org >>> >>> >> >> _______________________________________________ >> Hdf-forum is for HDF software users discussion. >> [email protected] >> >> http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org >> >> > > _______________________________________________ > Hdf-forum is for HDF software users discussion. > [email protected] > > http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org > >
_______________________________________________ Hdf-forum is for HDF software users discussion. [email protected] http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
