title: HDF5 Attribute unsigned long long value
body: <p>When I try and add an unsigned long long attribute to a dataset, the attribute is added but not the value.  Using a similiar method for an integer seems to work file.</p>
  
  <p>Am using HDF view to view the attributes.  The attribute names are displayed, but for the unsigned long long attributes, the values are not visible</p>
  
  <p>The code is as follows:</p>
  
  <pre><code>    herr_t Result;
  
  //Open the file
  hid_t DataFile = H5Fopen(FileName, H5F_ACC_RDWR, H5P_DEFAULT);
  
  //Open the dataset
  hid_t DataSet = H5Dopen2(DataFile, "/Summary", H5P_DEFAULT);
  
  //Create the data space for the attribute.
  hsize_t AttributeDims = 1;
  hid_t AttributeDataSpace = H5Screate_simple(1, &amp;AttributeDims , NULL);
  hid_t Attribute;
  
  //Attribute 1: Fail to write a long long attribute
  Attribute = H5Acreate2 (DataSet, "LongAttribute",  H5T_STD_U64BE, AttributeDataSpace, H5P_DEFAULT, H5P_DEFAULT);
  if (Attribute &lt; 0) {
      fprintf(stdout, "Failed to add the unsigned long long attribute to the file %s.", FileName);
      return false;
  }
  
  //Write the attribute data
  unsigned long long* ULLAttribute = (unsigned long long*) malloc(sizeof(unsigned long long) * 1);
  ULLAttribute[0] = (unsigned long long) 4;
  Result = H5Awrite(Attribute, H5T_NATIVE_ULLONG, ULLAttribute);
  if (Result &lt; 0) {
      fprintf(stdout, "Failed to write the unsigned long long attribute to the file %s.", FileName);
      return false;
  }
  
  //Attribute 2: Succesfully Write a integer attribute
  Attribute = H5Acreate2 (DataSet, "IntAttribute",  H5T_STD_I32BE, AttributeDataSpace, H5P_DEFAULT, H5P_DEFAULT);
  if (Attribute &lt; 0) {
      fprintf(stdout, "Failed to create the attribute for the file %s.", FileName);
      return false;
  }
  
  //Write the attribute data
  int32_t* IAttribute = (int32_t*) malloc(sizeof(int32_t) * 1);
  IAttribute[0] = (int32_t) 4;
  Result = H5Awrite(Attribute,  H5T_NATIVE_INT, IAttribute);
  if (Result &lt; 0) {
      fprintf(stdout, "Failed to add the integer attribute to the file %s.", FileName);
      return false;
  }
  
  //Close the attribute, Dataset and DataFile
  Result = H5Aclose(Attribute);
  Result = H5Dclose(DataSet);
  Result = H5Fclose(DataFile);
  </code></pre>
  
  <p>No error messages are displayed when the code is executed, but when the HDF5 file is viewed, both the attributes, "IntAttribute" and "LongAttribute" are visible, but the LongAttribute has no value.</p>
  
  <p>HFView 2.9, Fedora 20 on intel 64.</p>
  
  <p>Picking some of Timothy's question's
  Wrt:
      How come you are creating a simple dataspace for the attribute?
  I was chewing on storing the model parameters as attributes, kinda like key-value-pairs.  Many of the model parameters are simple scalar values.   </p>
  
  <p>Wrt:
      Following the same lines, how come your writing an array for the attribute?
  I'd edited an example, which had stored 2 values in an array.  I see from your example, you've malloc()'ed the space, which I'll use from now on as it seems more clear.</p>
  
  <p>Wrt: 
      Your on an Intel 64, yet your wanting to write big endian?
  Yes: this still puzzels me: both H5T_STD_I32BE and H5T_STD_I32LE work successfully, but neither H5T_STD_U64BE nor H5T_STD_U64LE show a value in HDFView.  I guess that somewhere in the HDF5 library it's checking for big vs little endian and handling the value accordingly, regardless of the parameter.  I'll try not to trip over this "feature" later with Postgresql binary  numbers which are always big endian values.</p>
  
  <p>The issue appears to be in HDFView, which is still not displaying the unsigned long long in the ull.h5 file produced by Timothy's code, or from my code:<img src="https://i.stack.imgur.com/9Rx7C.png" alt="enter image description here"></p>
  
  <p>I'm using HDFView 2.9 for Linux.  As Timothy mentioned this works in HDFView 2.10 I'll use h5dump in the meantime.</p>