1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright by The HDF Group. *
3 * Copyright by the Board of Trustees of the University of Illinois. *
4 * All rights reserved. *
5 * *
6 * This file is part of HDF5. The full HDF5 copyright notice, including *
7 * terms governing use, modification, and redistribution, is contained in *
8 * the COPYING file, which can be found at the root of the source code *
9 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10 * If you do not have access to either file, you may request a copy from *
11 * help@hdfgroup.org. *
12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13
14 /*
15 * Programmer: Quincey Koziol <koziol@hdfgroup.org>
16 * April 14, 2011
17 *
18 * Purpose: This program is run to generate an HDF5 data file with objects
19 * that use compound datatypes with no fields (now forbidden to
20 * be created by the library, as of v1.4.x). It must be built/run
21 * with a copy of the 1.2.x library.
22 */
23
24 #include <assert.h>
25 #include "hdf5.h"
26
27 #define FILENAME "bad_compound.h5"
28
main()29 int main()
30 {
31 hid_t file;
32 hid_t cmpd_dt;
33 hid_t sid;
34 hid_t did;
35 hid_t aid;
36 hid_t gid;
37 hsize_t dim = 1;
38 herr_t ret;
39
40 /* Create compound datatype, but don't insert fields */
41 cmpd_dt = H5Tcreate(H5T_COMPOUND, (size_t)8);
42 assert(cmpd_dt > 0);
43
44 /* Create File */
45 file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
46 assert(file > 0);
47
48 /* Create a dataspace to use */
49 sid = H5Screate_simple(1, &dim, NULL);
50 assert(sid > 0);
51
52 /* Create a dataset with the bad compound datatype */
53 did = H5Dcreate(file, "dataset", cmpd_dt, sid, H5P_DEFAULT);
54 assert(did > 0);
55
56 /* Create a group */
57 gid = H5Gcreate(file, "group", (size_t)0);
58 assert(gid > 0);
59
60 /* Create an attribute with the bad compound datatype */
61 aid = H5Acreate(gid, "attr", cmpd_dt, sid, H5P_DEFAULT);
62 assert(aid > 0);
63
64 /* Commit the datatype */
65 ret = H5Tcommit(file, "cmpnd", cmpd_dt);
66 assert(ret >= 0);
67
68 /* Close IDs */
69 ret = H5Gclose(gid);
70 assert(ret >= 0);
71 ret = H5Aclose(aid);
72 assert(ret >= 0);
73 ret = H5Sclose(sid);
74 assert(ret >= 0);
75 ret = H5Dclose(did);
76 assert(ret >= 0);
77 ret = H5Tclose(cmpd_dt);
78 assert(ret >= 0);
79 ret = H5Fclose(file);
80 assert(ret >= 0);
81
82 return(0);
83 }
84
85