Re: more enum questions...

NOTE: The netcdf-hdf mailing list is no longer active. The list archives are made available for historical reasons.

Hi Ed,

> I have some more enum questions!
> 
> Looking at the HDF5 users guide, I see the following example:
> 
> hid_t hdf_en_colors = H5Tcreate(H5T_ENUM, sizeof(short));
> short val;
>       H5Tenum_insert(hdf_en_colors, "RED",   (val=0,&val));
>       H5Tenum_insert(hdf_en_colors, "GREEN", (val=1,&val));
>       H5Tenum_insert(hdf_en_colors, "BLUE",  (val=2,&val));
>       H5Tenum_insert(hdf_en_colors, "WHITE", (val=3,&val));
>       H5Tenum_insert(hdf_en_colors, "BLACK", (val=4,&val));
> 
>      H5Dcreate(fileid,spaceid,hdf_en_colors,H5P_DEFAULT);
> 
> 
> I have three immediate questions:
> 
> 1 - Why is H5Tenum_create not used?

    It certainly could have been, there's no particular advantage one way or
the other (currently).  In the future, if we allow enums to have non-integer
base types (like an enum of floating-point values, with PI, E, etc. defined),
we'll encourage more people to use H5Tcreate_enum().

> 2 - In the above case, how does HDF5 choose the underlying integer
> type? Obviously it will be a short, but signed or unsigned? Big,
> little, or native endian? Or does it not matter?

    If you use H5Tcreate(), it uses the smallest "native" [signed] integer that
will hold the number of bytes passed in for the size.

> 3 - What is this strage way of setting the value of val inside the
> parameters to the function? In 20 years of C programming, I have never
> seen this technique!
    
    Ah, the comma operator is a strange and wondrous thing. :-)

        Quincey


  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-hdf archives: