From 6e2933348d89b7a2f5ce0621367875271a4699a6 Mon Sep 17 00:00:00 2001 From: Marius Muja Date: Wed, 15 Dec 2010 09:41:13 -0800 Subject: [PATCH] HDF5 compatibility fix --- src/cpp/flann/io/hdf5.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/cpp/flann/io/hdf5.h b/src/cpp/flann/io/hdf5.h index de3b2c1..7aa8a2c 100644 --- a/src/cpp/flann/io/hdf5.h +++ b/src/cpp/flann/io/hdf5.h @@ -75,7 +75,12 @@ void save_to_file(const flann::Matrix& dataset, const std::string& filename, hid_t space_id = H5Screate_simple(2, dimsf, NULL); hid_t memspace_id = H5Screate_simple(2, dimsf, NULL); - hid_t dataset_id = H5Dcreate2(file_id, name.c_str(), get_hdf5_type(), space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + hid_t dataset_id; +#if H5_VERS_MINOR >= 8 + dataset_id = H5Dcreate2(file_id, name.c_str(), get_hdf5_type(), space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); +#else + dataset_id = = H5Dcreate(file_id, name.c_str(), get_hdf5_type(), space_id, H5P_DEFAULT); +#endif CHECK_ERROR(dataset_id,"Error creating dataset in file."); status = H5Dwrite(dataset_id, get_hdf5_type(), memspace_id, space_id, H5P_DEFAULT, dataset.data ); @@ -96,7 +101,12 @@ void load_from_file(flann::Matrix& dataset, const std::string& filename, cons hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT); CHECK_ERROR(file_id,"Error opening hdf5 file."); - hid_t dataset_id = H5Dopen2(file_id, name.c_str(), H5P_DEFAULT); + hid_t dataset_id; +#if H5_VERS_MINOR >= 8 + dataset_id = H5Dopen2(file_id, name.c_str(), H5P_DEFAULT); +#else + dataset_id = H5Dopen(file_id, name.c_str()); +#endif CHECK_ERROR(dataset_id,"Error opening dataset in file."); hid_t space_id = H5Dget_space(dataset_id); @@ -142,7 +152,12 @@ void load_from_file(flann::Matrix& dataset, const std::string& filename, cons hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, plist_id); CHECK_ERROR(file_id,"Error opening hdf5 file."); H5Pclose(plist_id); - hid_t dataset_id = H5Dopen2(file_id, name.c_str(), H5P_DEFAULT); + hid_t dataset_id; +#if H5_VERS_MINOR >= 8 + dataset_id = H5Dopen2(file_id, name.c_str(), H5P_DEFAULT); +#else + dataset_id = H5Dopen(file_id, name.c_str()); +#endif CHECK_ERROR(dataset_id,"Error opening dataset in file."); hid_t space_id = H5Dget_space(dataset_id); -- GitLab