diff options
author | Gerd Heber <gheber@hdfgroup.org> | 2021-09-01 21:09:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 21:09:27 (GMT) |
commit | cf25524474a4012a70cc2bdb6eaddc402b5ea136 (patch) | |
tree | cf7e30d16a602e5146500158696d429a146cb2c2 /doxygen/dox/cookbook/Attributes.c | |
parent | 01fe2549a36d7635b2cbe6f6a57cbcce29c1335b (diff) | |
download | hdf5-cf25524474a4012a70cc2bdb6eaddc402b5ea136.zip hdf5-cf25524474a4012a70cc2bdb6eaddc402b5ea136.tar.gz hdf5-cf25524474a4012a70cc2bdb6eaddc402b5ea136.tar.bz2 |
A batch of life-cycle examples for different modules (#654)
* Create a tag file for permalinks.
* Added DOXYGEN_TAG_FILE.
* Added Doxygen life-cycle examples for different modules.
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'doxygen/dox/cookbook/Attributes.c')
-rw-r--r-- | doxygen/dox/cookbook/Attributes.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/doxygen/dox/cookbook/Attributes.c b/doxygen/dox/cookbook/Attributes.c new file mode 100644 index 0000000..f4e894f --- /dev/null +++ b/doxygen/dox/cookbook/Attributes.c @@ -0,0 +1,61 @@ +/* -*- c-file-style: "stroustrup" -*- */ + +#include "hdf5.h" + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +int +main(void) +{ + int ret_val = EXIT_SUCCESS; + + //! <!-- [large_attribute] --> + { + __label__ fail_attr, fail_aspace, fail_fapl, fail_file; + hid_t fapl, file, aspace, attr; + + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + ret_val = EXIT_FAILURE; + goto fail_fapl; + } +#if H5_VERSION_GE(1, 10, 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) { +#elif H5_VERSION_GE(1, 8, 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { +#else +#error Only HDF5 1.8.x and later supported. +#endif + ret_val = EXIT_FAILURE; + goto fail_file; + } + if ((file = H5Fcreate("large_attribute.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { + ret_val = EXIT_FAILURE; + goto fail_file; + } + + if ((aspace = H5Screate_simple(1, (hsize_t[]){1024 * 1024}, NULL)) < 0) { + ret_val = EXIT_FAILURE; + goto fail_aspace; + } + if ((attr = H5Acreate(file, "4MiB", H5T_IEEE_F32LE, aspace, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + ret_val = EXIT_FAILURE; + goto fail_attr; + } + + H5Aclose(attr); +fail_attr: + H5Sclose(aspace); +fail_aspace: + H5Fclose(file); +fail_file: + H5Pclose(fapl); +fail_fapl:; + } + //! <!-- [large_attribute] --> + + assert(ret_val == EXIT_SUCCESS); + + return ret_val; +} |