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

Hi Yury,

How did you create and write the attribute?

Binh-Minh

···

________________________________
From: Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org> on behalf of Yury Girshovich <yury.girshovich@caebridge.com>
Sent: Wednesday, July 24, 2013 1:04 PM
To: hdf-forum@lists.hdfgroup.org
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

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:hdf-forum-bounces@lists.hdfgroup.org] On Behalf Of Yury Girshovich
Sent: Wednesday, July 24, 2013 1:04 PM
To: hdf-forum@lists.hdfgroup.org
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.

Hi Binh-Minh,
It was not written in our organization. Here is the email from the person
who wrote it

We read and write the HDF using the python interface which does the
conversion to/from hdf internally.

Not being a C++ programmer he cannot help more than that. I can ask him for
the python script,
but I doubt it will help.
Thanks a lot,
Yury

···

On Wed, Jul 24, 2013 at 1:55 PM, Binh-Minh Ribler <bmribler@hdfgroup.org>wrote:

Hi Yury,

How did you create and write the attribute?

Binh-Minh
------------------------------
*From:* Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org> on behalf of
Yury Girshovich <yury.girshovich@caebridge.com>
*Sent:* Wednesday, July 24, 2013 1:04 PM
*To:* hdf-forum@lists.hdfgroup.org
*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

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org

http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

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 < Scott.Mitchell@exelisinc.com> 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:hdf-forum-bounces@lists.hdfgroup.org] *On
Behalf Of *Yury Girshovich

*Sent:* Wednesday, July 24, 2013 1:04 PM
*To:* hdf-forum@lists.hdfgroup.org
*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.
Hdf-forum@lists.hdfgroup.org

http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

Hi Yury,

Does the type attr_type passed in to the call attr.read(attr_type, &i); match the enum type? Did the program try to find out the attribute's type by calling some functions?

Also, when the crash occurs, could you tell if it's in the C++ API or in the C main library? Would you send me the error you got? Or, if you could do a stack dump, that would be helpful too.

Thanks,
Binh-Minh

···

________________________________
From: Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org> on behalf of Yury Girshovich <yury.girshovich@caebridge.com>
Sent: Wednesday, July 24, 2013 2:07 PM
To: HDF Users Discussion List
Subject: Re: [Hdf-forum] Reading enum bool attribute

Hi Binh-Minh,
It was not written in our organization. Here is the email from the person who wrote it

We read and write the HDF using the python interface which does the
conversion to/from hdf internally.

Not being a C++ programmer he cannot help more than that. I can ask him for the python script,
but I doubt it will help.
Thanks a lot,
Yury

On Wed, Jul 24, 2013 at 1:55 PM, Binh-Minh Ribler <bmribler@hdfgroup.org<mailto:bmribler@hdfgroup.org>> wrote:
Hi Yury,

How did you create and write the attribute?

Binh-Minh
________________________________
From: Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org<mailto:hdf-forum-bounces@lists.hdfgroup.org>> on behalf of Yury Girshovich <yury.girshovich@caebridge.com<mailto:yury.girshovich@caebridge.com>>
Sent: Wednesday, July 24, 2013 1:04 PM
To: hdf-forum@lists.hdfgroup.org<mailto:hdf-forum@lists.hdfgroup.org>
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

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org<mailto:Hdf-forum@lists.hdfgroup.org>
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

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 <hdf-forum-bounces@lists.hdfgroup.org> on behalf of Yury Girshovich <yury.girshovich@caebridge.com>
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 <Scott.Mitchell@exelisinc.com<mailto:Scott.Mitchell@exelisinc.com>> 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:hdf-forum-bounces@lists.hdfgroup.org<mailto:hdf-forum-bounces@lists.hdfgroup.org>] On Behalf Of Yury Girshovich

Sent: Wednesday, July 24, 2013 1:04 PM
To: hdf-forum@lists.hdfgroup.org<mailto:hdf-forum@lists.hdfgroup.org>
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.
Hdf-forum@lists.hdfgroup.org<mailto:Hdf-forum@lists.hdfgroup.org>
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

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

disassembly.odt (29.6 KB)

···

On Wed, Jul 24, 2013 at 3:02 PM, Binh-Minh Ribler <bmribler@hdfgroup.org>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 <hdf-forum-bounces@lists.hdfgroup.org> on behalf of
Yury Girshovich <yury.girshovich@caebridge.com>
*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 < > Scott.Mitchell@exelisinc.com> 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:hdf-forum-bounces@lists.hdfgroup.org] *On
Behalf Of *Yury Girshovich

*Sent:* Wednesday, July 24, 2013 1:04 PM
*To:* hdf-forum@lists.hdfgroup.org
*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.
Hdf-forum@lists.hdfgroup.org

http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org

http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

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 <hdf-forum-bounces@lists.hdfgroup.org> on behalf of Yury Girshovich <yury.girshovich@caebridge.com>
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 <bmribler@hdfgroup.org<mailto:bmribler@hdfgroup.org>> 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 <hdf-forum-bounces@lists.hdfgroup.org<mailto:hdf-forum-bounces@lists.hdfgroup.org>> on behalf of Yury Girshovich <yury.girshovich@caebridge.com<mailto:yury.girshovich@caebridge.com>>
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 <Scott.Mitchell@exelisinc.com<mailto:Scott.Mitchell@exelisinc.com>> 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:hdf-forum-bounces@lists.hdfgroup.org<mailto:hdf-forum-bounces@lists.hdfgroup.org>] On Behalf Of Yury Girshovich

Sent: Wednesday, July 24, 2013 1:04 PM
To: hdf-forum@lists.hdfgroup.org<mailto:hdf-forum@lists.hdfgroup.org>
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.
Hdf-forum@lists.hdfgroup.org<mailto:Hdf-forum@lists.hdfgroup.org>
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org<mailto:Hdf-forum@lists.hdfgroup.org>
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

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 <bmribler@hdfgroup.org>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 <hdf-forum-bounces@lists.hdfgroup.org> on behalf of
Yury Girshovich <yury.girshovich@caebridge.com>
*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 <bmribler@hdfgroup.org>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 <hdf-forum-bounces@lists.hdfgroup.org> on behalf of
Yury Girshovich <yury.girshovich@caebridge.com>
*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 < >> Scott.Mitchell@exelisinc.com> 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:hdf-forum-bounces@lists.hdfgroup.org] *On
Behalf Of *Yury Girshovich

*Sent:* Wednesday, July 24, 2013 1:04 PM
*To:* hdf-forum@lists.hdfgroup.org
*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.
Hdf-forum@lists.hdfgroup.org

http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org

http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org

http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

Ah, I see. I'm glad you got it. Thanks, Yury

Binh-Minh

···

________________________________
From: Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org> on behalf of Yury Girshovich <yury.girshovich@caebridge.com>
Sent: Thursday, July 25, 2013 4:15 PM
To: HDF Users Discussion List
Subject: Re: [Hdf-forum] Reading enum bool attribute

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 <bmribler@hdfgroup.org<mailto:bmribler@hdfgroup.org>> 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 <hdf-forum-bounces@lists.hdfgroup.org<mailto:hdf-forum-bounces@lists.hdfgroup.org>> on behalf of Yury Girshovich <yury.girshovich@caebridge.com<mailto:yury.girshovich@caebridge.com>>
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 <bmribler@hdfgroup.org<mailto:bmribler@hdfgroup.org>> 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 <hdf-forum-bounces@lists.hdfgroup.org<mailto:hdf-forum-bounces@lists.hdfgroup.org>> on behalf of Yury Girshovich <yury.girshovich@caebridge.com<mailto:yury.girshovich@caebridge.com>>
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 <Scott.Mitchell@exelisinc.com<mailto:Scott.Mitchell@exelisinc.com>> 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:hdf-forum-bounces@lists.hdfgroup.org<mailto:hdf-forum-bounces@lists.hdfgroup.org>] On Behalf Of Yury Girshovich

Sent: Wednesday, July 24, 2013 1:04 PM
To: hdf-forum@lists.hdfgroup.org<mailto:hdf-forum@lists.hdfgroup.org>
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.
Hdf-forum@lists.hdfgroup.org<mailto:Hdf-forum@lists.hdfgroup.org>
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org<mailto:Hdf-forum@lists.hdfgroup.org>
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org<mailto:Hdf-forum@lists.hdfgroup.org>
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org