From 9a4b225cb0967c1039daab738e6da436269f69e6 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Fri, 4 Jun 2021 07:29:02 -0700 Subject: VFD SWMR: sync with develop (#725) * Brings CMake updates from develop * Brings reduction in pedantic casts from develop * Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes * Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Formatted source * Bring over some VOL registration changes * VOL cleanup * H5VL_request_status_t substitutions * H5F.c cleanup * Minor API tweaks from develop * Moves H5G package init/teardown to H5Gint.c * H5G cleanup * H5M cleanup * H5SM cleanup * H5T cleanup * H5R cleanup * H5Lpublic.h cleanup * H5L cleanup * H5O cleanup * H5A, H5CS, and H5AC cleanup * Moved H5A init/teardown code to H5Aint.c * Moves H5D I/O functions to H5D.c * H5D cleanup * Misc minor cleanup * H5P close cleanup * H5Tpublic.h cleanup * Fixes err_compat test * H5PLpublic.h cleanup * Updates H5Ppublic.h * H5Fpublic.h updates * H5A.c cleanup * Brings over H5Aexists and related changes * Brings CMake shell testing changes from develop * Close callback changes * H5R and H5Tcommit normalization * err_compat test works now * H5O tweaks * Updates VOL registration code * Brings over H5VL_create_object * H5Tconv.c reformatting * H5T.c tweaks * Brings datatype and reference updates from develop * Brings VOL plugin loading changes from develop * Brings event sets from develop * Brings async functions over * Tools changes * Brings over many tools changes from develop * Brings VOL flags from develop * Fixes h5dump double/float tests * Updates h5repack tests * Brings h5diff test changes from develop * Last h5dump changes * Brings test changes from develop * Committing clang-format changes * Tidied h5_testing() * Brings chunk iteration code + misc from develop * Updates vds test * Enables external link parallel test * Brings updated property lists from develop * H5G changes from develop * H5MF cleanup * Brings vfd_swmr test back into CMake * Updates threadsafe test * Updates plist test * Brings recent changes from develop * Require a C++11 compiler to build the C++ wrappers (#693) * Committing clang-format changes * Requires a C++11 compiler to build the C++ wrappers Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Fix H5FD_mpio_Debug="rw" can report MPI_count instead of bytes (#699) * Removes pre-C99 build and header cruft (#700) * Assumes ANSI C headers exist * Assumes stdbool.h, stdint.h, and inttypes.h are present * Assumes the C++ compiler can handle stdint.h * Removes all work-arounds for missing functionality, especially stdbool.h Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Updates release documents * Brings parallel changes from develop * Adds a VFD/parallel check program for the VFD SWMR shell test * Updates MANIFEST * Disable building VFD SWMR acceptance tests on CMake * Removes err.h from genall5.c * Partial cleanup of H5Cpkg.h * Fixes printf specifiers in H5Cdbg.c * Java and fortran cmake changes (#694) * OESS-98 convert plugin option to FetchContent, add tests * Fixes for pkcfg files because of plugin option * OESS-98 fix tools test for plugins * Keep doxygen comments under 100 chars long - format hint * Whitespace * HDFFV-11144 - Reclassify CMake messages * HDFFV-11099/11100 added help text * Reworked switch statement to compare string instead * Fix typo * Update CDash mode * Correct name of threadsafe * Correct option name * Undo accidental commit * Note LLVM 10 to 11 format default changes * Update format plugin * Undo clang-format version 11 changes * One more correction * Update supported platforms * Revert whitespace changes * Correct whitespace * Changes from PR#3 * HDFFV-11213 added option to control gcc10 warnings diagnostics * HDFFV-11212 Use the new references correctly in JNI utility and tests * format source * Fix typo * Add new test file * HDFFV-11212 - update test and remove unused arg * Minor non-space formatting changes * Use H5I_INVALID_ID instead of "-1" * source formatting * add missing testfile, update jni function * Undo commit of debug code * remove mislocated file * Fix h5repack test for handling of fapls and id close * Update h5diff test files usage text * HDFFV-11212 add new ref tests for JNI export dataset * src format update * Remove blank line typo * src format typo * long double requires %Lg * Another long double foramt specifer S.B. %Lg * issue with t128bit test * Windows issue with h5dump and type. * Fix review issues * refactor function nesting and fix error checks * format fixes * Remove untested functions and javadoc quiet comments * Restore TRY block. * Change string append errors to memory exception * revert to H5_JNI_FATAL_ERROR - support functions need work * Add assertion error for h5util functions * remove duplicate function * format fix * Revert HD function error handling * Update copyright comments * GH #386 java folder copyright corrections * Whitespace * GH #359 implement and fix tools 1.6 API usage * remove excessive comments * Flip inits to correct ifdef section * rework ifdef to be simpler * format issue * Reformat ifdef inits * remove static attribute * format compliance * Update names * Revert because logic relies on float not being int * Changes noticed from creating merge of #412 * Double underscore change * Correct compiler version variable used * Remove header guard underscores * Whitespace cleanup * Split format source and commit changes on repo push * remove pre-split setting * Change windows TS to use older VS. * correct window os name * HDFFV-11212 JNI export util and Javadoc * Suggested review changes * Another change found * Committing clang-format changes * HDFFV-11113 long double in tools * HDFFV-11113 add note * Disable long double tests for now * HDFFV-11228 remove arbitrary CMake warning groups. * Make each flag a string * Some Javadoc warning fixes * Updated javadoc fixes * # WARNING: head commit changed in the meantime HDFFV-11229 Fix long double usage in tools and java Changed h5dump and h5ls to just print 128-bit for long double type. Added test and file for dataset and attributes with all three float types. * Committing clang-format changes * HDFFV-11229 Add release note * HDFFV-11229 windows testfile needed * fix typo * Remove non supported message text * HDFFV-11229 - change ldouble test to check both native and general * HDFFV-11229 add second file compare * HDFFV-11229 fix reference file * HDFFV-11229 autotools check two refs * HDFFV-11229 revert back to removal of NATIVE_LDOUBLE in tools output * Committing clang-format changes * Update release note * Update attribute type of ref file * Change source of ninja for macs * try port instead of brew * Recommended is to use brew. * Undo non long double changes * remove unneeded file * Fix perl and doxygen CMake code * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument * Add stamp files to BYPRODUCTS * Only one copy of file exists * Fix custom cmmand depends targets * Fix fortran custom command DEPENDS * Add LD_LIBRARY_PATH to tests * Add custom target for DEPENDS * Add h5detect conditionaly to generated target DEPENDS * Correct DEPENDS targets * Parallel builds need the mpi compiler for pkgconfig scripts. * install only if MPI build * Fortran target depends * Remove incorrect source attribute * doxygen adjustments * doxygen build updates * Correct version * Correct function version - function has been merged to 1.12 * Correct version string for map functions * Cleanup warnings for tools debug builds * TRILAB-227 - fix indexing for h5diff selections * Correct location of pos to index function call * TRILAB-227 Enable test * Quote subset args * Use MATCHES because of AppleClang * if blocks needed for build modes * Update list of DT platforms * VS2019 correctly displays float values * revert VS2019 change * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * Java reference functions updated enabled fortran in cmake gcc action yaml file java reference test changed to correctly test refs jni reference functions that create ids changed to use jni id logging * Correct BYPRODUCTS argument * Correct more genereated files BYPRODUCTS * BYPRODUCTS must have unique locations * Fix typo Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes alternative function enter/leave macro scheme (#678) * Committing clang-format changes * Converted BEGIN_FUNC, etc. macros to FUNC_ENTER * Rips out the BEGIN_FUNC, etc. macros * Removes 'end if', etc. comments from H5HL package * Committing clang-format changes * Fixes an H5EA iterate issue * Fixes an issue in the H5FA iterator code * Further cleanup in bin/trace after macro removal * Iterator changes in H5EA and H5FA Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Split H5L.c internal code to H5Lint.c (#691) * Committing clang-format changes * Splits internal parts of H5L.c to H5Lint.c Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Clean up type size checks in configure.ac (#702) * Committing clang-format changes * C++ warning and build fixes (#707) * Committing clang-format changes * C++ build and warning updates * Fixes all warnings on C++ (with gcc 9.3) * Updates CMake and Autotools C++ builds * Undo warning clobber Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes some DEC Alpha cruft from H5detect and H5private.h (#708) * Cleans up hsize_t and haddr_t size guessing (#709) * Cleans up definitions of haddr_t and hsize_t + cruft removal * Formatted source * Updates PGI C/C++ configurations (#715) * Updates PGI C/C++ configurations Tweaks some settings and configures pgc++ to use C++11 * Updated copyright information * Adds an Intel C++ configuration file (#716) * Adds an Intel C++ configuration file * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Updates bin/trace script to correctly wrap H5TRACE macros near clang-format column limit (#719) * Removes clang-format comments from H5O.c call * Fixes bin/trace to correctly wrap lines near the clang-format limit * Removed unused variable from bin/trace * Fixes issue with ccmake that prevents building Fortran (#723) ccmake runs iteratively, and the check_fortran_source_runs macros were clobbering a single output file that did not get updated on further configure iterations Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- CMakeLists.txt | 1 - MANIFEST | 7 +- bin/trace | 38 +++++-- c++/src/CMakeLists.txt | 7 -- c++/src/H5Cpp.h | 10 -- c++/src/H5DataSpace.cpp | 7 +- c++/src/H5DataType.cpp | 24 ++-- c++/src/H5DxferProp.cpp | 4 +- c++/src/H5Exception.cpp | 2 +- c++/src/H5File.cpp | 6 +- c++/src/H5LcreatProp.cpp | 4 +- c++/src/H5Location.cpp | 2 +- c++/src/H5PropList.cpp | 8 +- c++/test/dsets.cpp | 49 +++++++-- c++/test/tarray.cpp | 12 +- c++/test/tattr.cpp | 148 +++++++++++++++---------- c++/test/tcompound.cpp | 78 ++++++------- c++/test/tdspl.cpp | 18 +-- c++/test/tfile.cpp | 51 +++++---- c++/test/th5s.cpp | 20 ++-- c++/test/titerate.cpp | 29 +++-- c++/test/tlinks.cpp | 12 +- c++/test/tobject.cpp | 38 ++++--- c++/test/trefer.cpp | 162 ++++++++++++++------------- c++/test/ttypes.cpp | 9 +- c++/test/tvlstr.cpp | 54 +++++---- config/cmake/H5cxx_config.h.in | 16 --- config/cmake/H5pubconf.h.in | 6 - config/cmake/HDF5UseFortran.cmake | 76 ++----------- config/cmake/HDFCXXCompilerFlags.cmake | 25 ++--- config/cmake/HDFCompilerFlags.cmake | 22 ++-- config/cmake/HDFFortranCompilerFlags.cmake | 14 +-- config/cmake_ext_mod/ConfigureChecks.cmake | 9 -- config/cmake_ext_mod/HDFCXXTests.cpp | 46 -------- config/cmake_ext_mod/HDFUseCXX.cmake | 99 ----------------- config/gnu-cxxflags | 1 + config/gnu-warnings/cxx-9 | 2 + config/intel-cxxflags | 128 +++++++++++++++++++++ config/linux-gnulibc1 | 14 ++- config/pgi-cxxflags | 96 ++++++++++++++++ config/pgi-flags | 63 +++++------ configure.ac | 20 +--- hl/c++/src/H5PacketTable.cpp | 8 +- hl/c++/src/H5PacketTable.h | 3 +- hl/c++/test/ptableTest.cpp | 12 +- m4/aclocal_cxx.m4 | 79 ------------- release_docs/RELEASE.txt | 27 ++++- src/H5O.c | 9 +- src/H5detect.c | 15 --- src/H5private.h | 16 +-- src/H5public.h | 171 ++++++++--------------------- tools/test/perform/overhead.c | 4 - 52 files changed, 834 insertions(+), 947 deletions(-) delete mode 100644 config/cmake/H5cxx_config.h.in delete mode 100644 config/cmake_ext_mod/HDFCXXTests.cpp delete mode 100644 config/cmake_ext_mod/HDFUseCXX.cmake create mode 100644 config/gnu-warnings/cxx-9 create mode 100644 config/intel-cxxflags create mode 100644 config/pgi-cxxflags delete mode 100644 m4/aclocal_cxx.m4 diff --git a/CMakeLists.txt b/CMakeLists.txt index ec5c0ae..734d945 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1130,7 +1130,6 @@ if (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++") endif () endif () - include (${HDF_RESOURCES_EXT_DIR}/HDFUseCXX.cmake) include (${HDF_RESOURCES_DIR}/HDFCXXCompilerFlags.cmake) add_subdirectory (c++) diff --git a/MANIFEST b/MANIFEST index 4aee966..b73a726 100644 --- a/MANIFEST +++ b/MANIFEST @@ -40,7 +40,6 @@ ./.github/workflows/main.yml _DO_NOT_DISTRIBUTE_ ./.github/workflows/pr-check.yml _DO_NOT_DISTRIBUTE_ -./m4/aclocal_cxx.m4 ./m4/aclocal_fc.m4 ./m4/aclocal_fc.f90 ./m4/ax_check_class.m4 @@ -136,6 +135,7 @@ ./config/cygwin ./config/ibm-aix ./config/ibm-flags +./config/intel-cxxflags ./config/intel-fflags ./config/intel-flags ./config/libhdf5.pc.in @@ -147,6 +147,7 @@ ./config/lt_vers.am ./config/Makefile.am.blank ./config/netbsd +./config/pgi-cxxflags ./config/pgi-fflags ./config/pgi-flags ./config/solaris @@ -172,6 +173,7 @@ ./config/gnu-warnings/cxx-4.8 ./config/gnu-warnings/cxx-4.9 ./config/gnu-warnings/cxx-5 +./config/gnu-warnings/cxx-9 ./config/gnu-warnings/cxx-error-5 ./config/gnu-warnings/cxx-error-general ./config/gnu-warnings/cxx-noerror-5 @@ -3592,7 +3594,6 @@ ./config/cmake/CTestCustom.cmake ./config/cmake/fileCompareTest.cmake ./config/cmake/FindHDFS.cmake -./config/cmake/H5cxx_config.h.in ./config/cmake/H5pubconf.h.in ./config/cmake/hdf5-config.cmake.in ./config/cmake/hdf5-config-version.cmake.in @@ -3627,11 +3628,9 @@ ./config/cmake_ext_mod/hdf.bmp ./config/cmake_ext_mod/hdf.icns ./config/cmake_ext_mod/hdf.ico -./config/cmake_ext_mod/HDFCXXTests.cpp ./config/cmake_ext_mod/HDFLibMacros.cmake ./config/cmake_ext_mod/HDFMacros.cmake ./config/cmake_ext_mod/HDFTests.c -./config/cmake_ext_mod/HDFUseCXX.cmake ./config/cmake_ext_mod/HDFUseFortran.cmake ./config/cmake_ext_mod/NSIS.InstallOptions.ini.in ./config/cmake_ext_mod/NSIS.template.in diff --git a/bin/trace b/bin/trace index 0eef8ce..1f40227 100755 --- a/bin/trace +++ b/bin/trace @@ -352,10 +352,32 @@ sub rewrite_func ($$$$$) { $argtrace = "H5ARG_TRACE" . scalar(@arg_str) . "(FUNC, \""; $trace .= join("", @arg_str) . "\""; $argtrace .= join("", @arg_str) . "\""; - my $len = 4 + length $trace; # Add 4, for indenting the line - for (@arg_name) { - # Wrap lines that will be longer than the limit, after ');' is added - if ($len + length >= ($max_trace_macro_line_len - 2)) { + + # Add 4 for indenting the line + my $len = 4 + length($trace); + + for my $i (0 .. $#arg_name) { + # Handle wrapping + + # Be VERY careful here! clang-format and this script MUST agree + # on which lines get wrapped or there will be churn as each tries + # to undo the other's output. + # + # TWO cases must be handled: + # 1) The argument is that last one and ');' will be appended + # 2) The argument is NOT the last one and ',' will be appended + # + # NB: clang-format does NOT consider terminal newlines when + # counting columns for the ColumnLimit + # + # The extra '2' added after $len includes the ', ' that would be + # added BEFORE the argument. + # + my $adjust = ($i + 1 == scalar(@arg_str)) ? 2 : 1; + my $len_if_added = $len + 2 + length($arg_name[$i]) + $adjust; + + # Wrap lines that will be longer than the limit + if ($len_if_added > $max_trace_macro_line_len) { # Wrap line, with indention $trace .= ",\n "; $len = 13; # Set to 13, for indention @@ -371,9 +393,11 @@ sub rewrite_func ($$$$$) { } # Append argument - $trace .= "$_"; - $argtrace .= ", $_"; - $len += length; # Add length of appended argument name + $trace .= "$arg_name[$i]"; + $argtrace .= ", $arg_name[$i]"; + + # Add length of appended argument name + $len += length($arg_name[$i]); } # Append final ');' for macro diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 835d422..2a37dea 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -2,13 +2,6 @@ cmake_minimum_required (VERSION 3.12) project (HDF5_CPP_SRC CXX) #----------------------------------------------------------------------------- -# Generate configure file -#----------------------------------------------------------------------------- -configure_file (${HDF_RESOURCES_DIR}/H5cxx_config.h.in - ${HDF5_SRC_BINARY_DIR}/H5cxx_pubconf.h -) - -#----------------------------------------------------------------------------- # Define cpp Library #----------------------------------------------------------------------------- set (CPP_SOURCES diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index 9272bdb..202d584 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -48,14 +48,4 @@ #include "H5File.h" #include "H5Library.h" -/* Some C++ compilers do not have offsetof macro; define to bypass the problem - - BMR- -EIP- 2007/08/01 -*/ -#ifndef H5_CXX_HAVE_OFFSETOF -#ifdef HOFFSET -#undef HOFFSET -#endif -#define HOFFSET(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER) -#endif - #endif // H5Cpp_H diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index c20a88c..342e9fa 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -88,9 +88,8 @@ const DataSpace &DataSpace::ALL = *getConstant(); ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace(H5S_class_t type) : IdComponent() +DataSpace::DataSpace(H5S_class_t type) : IdComponent(), id{H5Screate(type)} { - id = H5Screate(type); if (id < 0) { throw DataSpaceIException("DataSpace constructor", "H5Screate failed"); } @@ -105,9 +104,9 @@ DataSpace::DataSpace(H5S_class_t type) : IdComponent() ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims) : IdComponent() +DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims) + : IdComponent(), id{H5Screate_simple(rank, dims, maxdims)} { - id = H5Screate_simple(rank, dims, maxdims); if (id < 0) { throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed"); } diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 3228dcb..cdf28cf 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -76,10 +76,9 @@ DataType::DataType(const hid_t existing_id) : H5Object(), id(existing_id), encod ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5T_class_t type_class, size_t size) + : H5Object(), id{H5Tcreate(type_class, size)}, encoded_buf(NULL), buf_size(0) { - // Call C routine to create the new datatype - id = H5Tcreate(type_class, size); if (id < 0) { throw DataTypeIException("DataType constructor", "H5Tcreate failed"); } @@ -97,9 +96,10 @@ DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), enco // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- DataType::DataType(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) - : H5Object(), encoded_buf(NULL), buf_size(0) + : H5Object(), id{H5Location::p_dereference(loc.getId(), ref, ref_type, plist, + "constructor - by dereference")}, + encoded_buf(NULL), buf_size(0) { - id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference"); } //-------------------------------------------------------------------------- @@ -146,10 +146,9 @@ DataType::DataType(const DataType &original) : H5Object(), id(original.id), enco // unnecessarily and will produce undefined behavior. // -BMR, Apr 2015 //-------------------------------------------------------------------------- -DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const PredType &pred_type) + : H5Object(), id{H5Tcopy(pred_type.getId())}, encoded_buf(NULL), buf_size(0) { - // Call C routine to copy the datatype - id = H5Tcopy(pred_type.getId()); if (id < 0) throw DataTypeIException("DataType constructor", "H5Tcopy failed"); } @@ -168,9 +167,9 @@ DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), b // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const char *dtype_name) + : H5Object(), id{p_opentype(loc, dtype_name)}, encoded_buf(NULL), buf_size(0) { - id = p_opentype(loc, dtype_name); } //-------------------------------------------------------------------------- @@ -188,9 +187,8 @@ DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(), // -BMR, Dec 2016 //-------------------------------------------------------------------------- DataType::DataType(const H5Location &loc, const H5std_string &dtype_name) - : H5Object(), encoded_buf(NULL), buf_size(0) + : H5Object(), id{p_opentype(loc, dtype_name.c_str())}, encoded_buf(NULL), buf_size(0) { - id = p_opentype(loc, dtype_name.c_str()); } //-------------------------------------------------------------------------- @@ -318,7 +316,7 @@ DataType::encode() // Allocate buffer and call C function again to encode if (buf_size > 0) { - encoded_buf = (unsigned char *)HDcalloc((size_t)1, buf_size); + encoded_buf = static_cast(HDcalloc(1, buf_size)); ret_value = H5Tencode(id, encoded_buf, &buf_size); if (ret_value < 0) { throw DataTypeIException("DataType::encode", "H5Tencode failed"); diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index 43ea6f4..40faac2 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -175,7 +175,7 @@ DSetMemXferPropList::getBuffer(void **tconv, void **bkg) const void DSetMemXferPropList::setPreserve(bool status) const { - herr_t ret_value = H5Pset_preserve(id, (hbool_t)status); + herr_t ret_value = H5Pset_preserve(id, static_cast(status)); if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::setPreserve", "H5Pset_preserve failed"); } @@ -314,7 +314,7 @@ DSetMemXferPropList::getDataTransform() const H5std_string expression; // Preliminary call to get the expression's length - ssize_t exp_len = H5Pget_data_transform(id, NULL, (size_t)0); + ssize_t exp_len = H5Pget_data_transform(id, NULL, 0); // If H5Pget_data_transform returns a negative value, raise an exception if (exp_len < 0) { diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 6769439..a42c151 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -25,7 +25,7 @@ const char Exception::DEFAULT_MSG[] = "No detailed information provided"; ///\brief Default constructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception() +Exception::Exception() : detail_message{""}, func_name{""} { } diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 9a6f191..f92171b 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -165,9 +165,8 @@ H5File::p_get_file(const char *name, unsigned int flags, const FileCreatPropList // constructor is needed by the library in order to return // an object, H5File doesn't need it. -BMR (HDFFV-8766 partially) //-------------------------------------------------------------------------- -H5File::H5File(hid_t existing_id) : Group() +H5File::H5File(hid_t existing_id) : Group(), id{existing_id} { - id = existing_id; incRefCount(); // increment number of references to this id } @@ -180,9 +179,8 @@ H5File::H5File(hid_t existing_id) : Group() ///\param original - IN: H5File instance to copy // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const H5File &original) : Group(original) +H5File::H5File(const H5File &original) : Group(original), id{original.getId()} { - id = original.getId(); incRefCount(); // increment number of references to this id } diff --git a/c++/src/H5LcreatProp.cpp b/c++/src/H5LcreatProp.cpp index 63fe861..3851d56 100644 --- a/c++/src/H5LcreatProp.cpp +++ b/c++/src/H5LcreatProp.cpp @@ -121,7 +121,7 @@ LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) void LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const { - herr_t ret_value = H5Pset_create_intermediate_group(id, (unsigned)crt_intmd_group); + herr_t ret_value = H5Pset_create_intermediate_group(id, static_cast(crt_intmd_group)); // Throw exception if H5Pset_create_intermediate_group returns failure if (ret_value < 0) { throw PropListIException("setCreateIntermediateGroup", "H5Pset_create_intermediate_group failed"); @@ -146,7 +146,7 @@ LinkCreatPropList::getCreateIntermediateGroup() const throw PropListIException("getCreateIntermediateGroup", "H5Pget_create_intermediate_group failed"); } - return ((bool)crt_intmd_group); + return static_cast(crt_intmd_group); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 065de0c..bb754a2 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -351,7 +351,7 @@ H5Location::getComment(const char *name, size_t buf_size) const H5std_string comment; // Preliminary call to get the comment's length - ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, (size_t)0, H5P_DEFAULT); + ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, 0, H5P_DEFAULT); // If H5Oget_comment_by_name returns a negative value, raise an exception if (comment_len < 0) { diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 8b45f79..46e4931 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -113,11 +113,8 @@ PropList::PropList(const PropList &original) : IdComponent(), id(original.id) // property's id to H5P_DEFAULT. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList::PropList(const hid_t plist_id) : IdComponent() +PropList::PropList(const hid_t plist_id) : IdComponent(), id{H5P_DEFAULT} { - if (plist_id <= 0) - id = H5P_DEFAULT; - H5I_type_t id_type = H5Iget_type(plist_id); switch (id_type) { case H5I_GENPROP_CLS: @@ -633,11 +630,12 @@ PropList::setProperty(const char *name, void *value) const void PropList::setProperty(const char *name, const char *charptr) const { - herr_t ret_value = H5Pset(id, name, (const void *)charptr); + herr_t ret_value = H5Pset(id, name, static_cast(charptr)); if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } + //-------------------------------------------------------------------------- // Function: PropList::setProperty ///\brief This is an overloaded member function, provided for convenience. diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index a16061b..53b56fc 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -23,6 +23,8 @@ ***************************************************************************/ +#include +#include #include using std::cerr; using std::endl; @@ -189,9 +191,9 @@ test_simple_io(H5File &file) SUBTEST("Simple I/O"); - int points[100][200]; - int check[100][200]; - int i, j, n; + auto points = new int[100][200]; + auto check = new int[100][200](); + int i, j, n; // Initialize the dataset for (i = n = 0; i < 100; i++) { @@ -233,6 +235,8 @@ test_simple_io(H5File &file) // clean up and return with success delete[] tconv_buf; + delete[] points; + delete[] check; PASSED(); return 0; } // end try @@ -244,6 +248,8 @@ test_simple_io(H5File &file) // clean up and return with failure delete[] tconv_buf; + delete[] points; + delete[] check; return -1; } } // test_simple_io @@ -408,6 +414,13 @@ filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[ size_t *buf_size, void **buf) // H5_ATTR_UNUSED variables caused warning, but taking them out caused failure. { + // Unused + (void)flags; + (void)cd_nelmts; + (void)cd_values; + (void)buf_size; + (void)buf; + return nbytes; } @@ -431,8 +444,8 @@ test_compression(H5File &file) const char *not_supported; not_supported = " Deflate compression is not enabled."; #endif /* H5_HAVE_FILTER_DEFLATE */ - int points[100][200]; - int check[100][200]; + auto points = new int[100][200]; + auto check = new int[100][200]; hsize_t i, j, n; // Initialize the dataset @@ -667,6 +680,8 @@ test_compression(H5File &file) */ delete dataset; delete[] tconv_buf; + delete[] points; + delete[] check; return 0; } // end try @@ -678,6 +693,8 @@ test_compression(H5File &file) // clean up and return with failure delete dataset; delete[] tconv_buf; + delete[] points; + delete[] check; return -1; } } // test_compression @@ -713,6 +730,9 @@ test_nbit_compression(H5File &file) SUBTEST("N-bit compression (setup)"); + HDmemset(orig_data, 0, DIM1 * DIM2 * sizeof(s1_t)); + HDmemset(new_data, 0, DIM1 * DIM2 * sizeof(s1_t)); + try { // Define datatypes of members of compound datatype IntType i_type(PredType::NATIVE_INT); @@ -1079,7 +1099,7 @@ test_getnativeinfo(H5File &file) H5O_native_info_t ninfo; HDmemset(&ninfo, 0, sizeof(ninfo)); dataset.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR); - verify_val(ninfo.hdr.nchunks, 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__); + verify_val(static_cast(ninfo.hdr.nchunks), 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__); dataset.close(); // Open the dataset we created above and then close it. This is one @@ -1087,7 +1107,7 @@ test_getnativeinfo(H5File &file) dataset = file.openDataSet(DSET_DEFAULT_NAME); HDmemset(&ninfo, 0, sizeof(ninfo)); dataset.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_ALL); - verify_val(ninfo.hdr.nchunks, 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__); + verify_val(static_cast(ninfo.hdr.nchunks), 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__); dataset.close(); PASSED(); @@ -1139,12 +1159,15 @@ test_chunk_cache(const FileAccPropList &fapl) dapl.getChunkCache(nslots_4, nbytes_4, w0_4); verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); verify_val(nbytes_1, nbytes_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); - verify_val(w0_1, w0_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + if (abs(w0_1 - w0_4) > DBL_EPSILON) + TestErrPrintf("%d: w0_1 and w0_4 different: w0_1=%f, " + "w0_4=%f\n", + __LINE__, w0_1, w0_4); // Set a link access property on dapl to verify property list inheritance - dapl.setNumLinks((size_t)134); + dapl.setNumLinks(134); size_t nlinks = dapl.getNumLinks(); - verify_val(nlinks, (size_t)134, "DSetAccPropList::getNumLinks", __LINE__, __FILE__); + verify_val(static_cast(nlinks), 134, "DSetAccPropList::getNumLinks", __LINE__, __FILE__); // Make a copy of the external fapl FileAccPropList fapl_local(fapl); @@ -1255,7 +1278,8 @@ test_virtual() // Get the current layout, should be default, H5D_CONTIGUOUS H5D_layout_t layout = dcpl.getLayout(); - verify_val(layout, H5D_CONTIGUOUS, "DSetCreatPropList::getLayout", __LINE__, __FILE__); + verify_val(static_cast(layout), static_cast(H5D_CONTIGUOUS), + "DSetCreatPropList::getLayout", __LINE__, __FILE__); // Create fixed mapping hsize_t dims[RANK]; @@ -1277,7 +1301,8 @@ test_virtual() // Get and verify the new layout layout = dcpl.getLayout(); - verify_val(layout, H5D_VIRTUAL, "DSetCreatPropList::getLayout", __LINE__, __FILE__); + verify_val(static_cast(layout), static_cast(H5D_VIRTUAL), "DSetCreatPropList::getLayout", + __LINE__, __FILE__); PASSED(); return 0; diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index 7525c5f..c7c0b65 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -83,7 +83,8 @@ test_array_compound_array() for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) { wdata[idxi][idxj].i = static_cast(idxi * 10 + idxj); for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) { - float temp = idxi * 10.0 + idxj * 2.5 + idxk; + float temp = static_cast(idxi) * 10.0F + static_cast(idxj) * 2.5F + + static_cast(idxk); wdata[idxi][idxj].f[idxk] = temp; } } // end for @@ -242,7 +243,7 @@ test_array_compound_array() verify_val(ndims, ARRAY1_RANK, "f2_atype_check.getArrayNDims", __LINE__, __FILE__); // Get the array dimensions - HDmemset(rdims1, 0, H5S_MAX_RANK); + HDmemset(rdims1, 0, sizeof(rdims1)); f2_atype_check.getArrayDims(rdims1); // Check the array dimensions @@ -288,7 +289,7 @@ test_array_compound_array() /* * Helper routine to demonstrate the issue in HDFFV-9562 */ -H5::DataType +static H5::DataType getArr() { hsize_t *dims = new hsize_t; @@ -388,10 +389,11 @@ test_array_info() for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) { wdata[idxi][idxj].i = static_cast(idxi * 10 + idxj); for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) { - float temp = idxi * 10.0 + idxj * 2.5 + idxk; + float temp = static_cast(idxi) * 10.0F + static_cast(idxj) * 2.5F + + static_cast(idxk); wdata[idxi][idxj].f[idxk] = temp; } - } // end for + } try { // Create File diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index adaa237..45ccc98 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -17,6 +17,8 @@ C attribute interface (H5A) ***************************************************************************/ +#include +#include #include using std::cerr; using std::endl; @@ -93,7 +95,7 @@ struct attr4_struct { const H5std_string ATTR5_NAME("Attr5"); const int ATTR5_RANK = 0; -float attr_data5 = (float)-5.123; // Test data for 5th attribute +float attr_data5 = -5.123f; // Test data for 5th attribute /* Info for another attribute */ const H5std_string ATTR1A_NAME("Attr1_a"); @@ -208,7 +210,7 @@ test_attr_basic_write() // Check storage size for attribute hsize_t attr_size = gr_attr.getStorageSize(); - verify_val((long)attr_size, (long)(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)), + verify_val(static_cast(attr_size), static_cast(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)), "Attribute::getStorageSize", __LINE__, __FILE__); // Try to create the same attribute again (should fail) @@ -227,7 +229,7 @@ test_attr_basic_write() // Check storage size for attribute attr_size = gr_attr.getStorageSize(); - verify_val((long)attr_size, (long)(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)), + verify_val(static_cast(attr_size), static_cast(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)), "Attribute::getStorageSize", __LINE__, __FILE__); PASSED(); @@ -298,8 +300,10 @@ test_attr_getname() ssize_t name_size = 0; // actual length of attribute name name_size = fattr1.getName(fattr1_name, buf_size + 1); CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__); - verify_val((size_t)name_size, FATTR1_NAME.length(), "Attribute::getName", __LINE__, __FILE__); - verify_val((const char *)fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); + verify_val(static_cast(name_size), FATTR1_NAME.length(), "Attribute::getName", __LINE__, + __FILE__); + verify_val(const_cast(fattr1_name), FATTR1_NAME, "Attribute::getName", __LINE__, + __FILE__); delete[] fattr1_name; // 2. With arbitrary buf_size that is smaller than the name's length. @@ -310,9 +314,10 @@ test_attr_getname() HDmemset(fattr1_name, 0, buf_size + 1); name_size = fattr1.getName(fattr1_name, buf_size + 1); CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__); - verify_val((size_t)name_size, FATTR1_NAME.size(), "Attribute::getName", __LINE__, __FILE__); - verify_val((const char *)fattr1_name, (const char *)short_name, "Attribute::getName", __LINE__, + verify_val(static_cast(name_size), FATTR1_NAME.size(), "Attribute::getName", __LINE__, __FILE__); + verify_val(const_cast(fattr1_name), const_cast(short_name), + "Attribute::getName", __LINE__, __FILE__); delete[] fattr1_name; // 3. With a buf_size that equals the name's length. @@ -525,7 +530,7 @@ test_attr_basic_read() H5O_info2_t oinfo; HDmemset(&oinfo, 0, sizeof(oinfo)); dataset.getObjinfo(oinfo, H5O_INFO_NUM_ATTRS); - verify_val(oinfo.num_attrs, 3, "DataSet::getObjinfo", __LINE__, __FILE__); + verify_val(static_cast(oinfo.num_attrs), 3, "DataSet::getObjinfo", __LINE__, __FILE__); // Open an attribute for the dataset Attribute ds_attr = dataset.openAttribute(ATTR1_NAME); @@ -553,7 +558,7 @@ test_attr_basic_read() // Verify the correct number of attributes another way HDmemset(&oinfo, 0, sizeof(oinfo)); group.getObjinfo(oinfo, H5O_INFO_NUM_ATTRS); - verify_val(oinfo.num_attrs, 1, "Group::getObjinfo", __LINE__, __FILE__); + verify_val(static_cast(oinfo.num_attrs), 1, "Group::getObjinfo", __LINE__, __FILE__); // Open an attribute for the group Attribute gr_attr = group.openAttribute(ATTR2_NAME); @@ -678,10 +683,10 @@ test_attr_compound_read() H5O_info2_t oinfo; HDmemset(&oinfo, 0, sizeof(oinfo)); dataset.getObjinfo(oinfo, H5O_INFO_NUM_ATTRS); - verify_val(oinfo.num_attrs, 1, "DataSet::getObjinfo", __LINE__, __FILE__); + verify_val(static_cast(oinfo.num_attrs), 1, "DataSet::getObjinfo", __LINE__, __FILE__); // Open 1st attribute for the dataset - Attribute attr = dataset.openAttribute((unsigned)0); + Attribute attr = dataset.openAttribute(static_cast(0)); /* Verify Dataspace */ @@ -695,14 +700,17 @@ test_attr_compound_read() // Get the dims of the dataspace and verify them int ndims = space.getSimpleExtentDims(dims); verify_val(ndims, ATTR4_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - verify_val((long)dims[0], (long)ATTR4_DIM1, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - verify_val((long)dims[1], (long)ATTR4_DIM2, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val(static_cast(dims[0]), static_cast(ATTR4_DIM1), + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val(static_cast(dims[1]), static_cast(ATTR4_DIM2), + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); // Get the class of the datatype that is used by attr H5T_class_t type_class = attr.getTypeClass(); // Verify that the type is of compound datatype - verify_val(type_class, H5T_COMPOUND, "Attribute::getTypeClass", __LINE__, __FILE__); + verify_val(static_cast(type_class), static_cast(H5T_COMPOUND), "Attribute::getTypeClass", + __LINE__, __FILE__); // Get the compound datatype CompType datatype = attr.getCompType(); @@ -734,11 +742,13 @@ test_attr_compound_read() // Get and verify the type class of the first member type_class = datatype.getMemberClass(0); - verify_val(type_class, H5T_INTEGER, "DataType::getMemberClass", __LINE__, __FILE__); + verify_val(static_cast(type_class), static_cast(H5T_INTEGER), "DataType::getMemberClass", + __LINE__, __FILE__); // Get and verify the order of this member's type IntType i_type = datatype.getMemberIntType(0); H5T_order_t order = i_type.getOrder(); - verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__); + verify_val(static_cast(order), static_cast(PredType::NATIVE_INT.getOrder()), + "DataType::getOrder", __LINE__, __FILE__); // Get and verify the size of this member's type size = i_type.getSize(); @@ -746,21 +756,25 @@ test_attr_compound_read() // Get and verify class, order, and size of the second member's type type_class = datatype.getMemberClass(1); - verify_val(type_class, H5T_FLOAT, "DataType::getMemberClass", __LINE__, __FILE__); + verify_val(static_cast(type_class), static_cast(H5T_FLOAT), "DataType::getMemberClass", + __LINE__, __FILE__); FloatType f_type = datatype.getMemberFloatType(1); order = f_type.getOrder(); - verify_val(order, PredType::NATIVE_DOUBLE.getOrder(), "DataType::getOrder", __LINE__, __FILE__); + verify_val(static_cast(order), static_cast(PredType::NATIVE_DOUBLE.getOrder()), + "DataType::getOrder", __LINE__, __FILE__); size = f_type.getSize(); verify_val(size, PredType::NATIVE_DOUBLE.getSize(), "DataType::getSize", __LINE__, __FILE__); // Get and verify class, order, and size of the third member's type type_class = datatype.getMemberClass(2); - verify_val(type_class, H5T_INTEGER, "DataType::getMemberClass", __LINE__, __FILE__); + verify_val(static_cast(type_class), static_cast(H5T_INTEGER), "DataType::getMemberClass", + __LINE__, __FILE__); // Note: H5T_INTEGER is correct here! StrType s_type = datatype.getMemberStrType(2); order = s_type.getOrder(); - verify_val(order, PredType::NATIVE_SCHAR.getOrder(), "DataType::getOrder", __LINE__, __FILE__); + verify_val(static_cast(order), static_cast(PredType::NATIVE_SCHAR.getOrder()), + "DataType::getOrder", __LINE__, __FILE__); size = s_type.getSize(); verify_val(size, PredType::NATIVE_SCHAR.getSize(), "DataType::getSize", __LINE__, __FILE__); @@ -902,15 +916,18 @@ test_attr_scalar_read() // Read attribute information float read_data2 = 0.0; // Buffer for reading 1st attribute ds_attr.read(PredType::NATIVE_FLOAT, &read_data2); - if (HDfabs(read_data2 - attr_data5) > FP_EPSILON) - verify_val(read_data2, attr_data5, FP_EPSILON, "Attribute::read", __LINE__, __FILE__); + if (abs(read_data2 - attr_data5) > FLT_EPSILON) + TestErrPrintf("%d: attribute data different: read_data2=%f, " + "attr_data5=%f\n", + __LINE__, static_cast(read_data2), static_cast(attr_data5)); // Get the dataspace of the attribute DataSpace att_space = ds_attr.getSpace(); // Make certain the dataspace is scalar H5S_class_t space_type = att_space.getSimpleExtentType(); - verify_val(space_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__); + verify_val(static_cast(space_type), static_cast(H5S_SCALAR), + "DataSpace::getSimpleExtentType", __LINE__, __FILE__); PASSED(); } // end try block @@ -1029,7 +1046,7 @@ test_attr_mult_read() verify_val(num_attrs, 3, "DataSet::getNumAttrs", __LINE__, __FILE__); // Open 1st attribute for the dataset - Attribute attr = dataset.openAttribute((unsigned)0); + Attribute attr = dataset.openAttribute(static_cast(0)); /* Verify Dataspace */ @@ -1042,10 +1059,10 @@ test_attr_mult_read() // Get the dims of the dataspace and verify them hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions - int ndims = space.getSimpleExtentDims(dims); - if ((long)dims[0] != (long)ATTR1_DIM1) + (void)space.getSimpleExtentDims(dims); + if (dims[0] != ATTR1_DIM1) TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %llu\n", __LINE__, - (int)dims[0], ATTR1_DIM1); + static_cast(dims[0]), ATTR1_DIM1); /* Verify Datatype */ @@ -1053,14 +1070,16 @@ test_attr_mult_read() H5T_class_t type_class = attr.getTypeClass(); // Verify that the type is of integer datatype - verify_val(type_class, H5T_INTEGER, "Attribute::getTypeClass", __LINE__, __FILE__); + verify_val(static_cast(type_class), static_cast(H5T_INTEGER), "Attribute::getTypeClass", + __LINE__, __FILE__); // Get the integer datatype IntType i_type1 = attr.getIntType(); // Get and verify the order of this type H5T_order_t order = i_type1.getOrder(); - verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__); + verify_val(static_cast(order), static_cast(PredType::NATIVE_INT.getOrder()), + "DataType::getOrder", __LINE__, __FILE__); // Get and verify the size of this type size_t size = i_type1.getSize(); @@ -1083,7 +1102,7 @@ test_attr_mult_read() space.close(); // Open 2nd attribute for the dataset - attr = dataset.openAttribute((unsigned)1); + attr = dataset.openAttribute(static_cast(1)); /* Verify Dataspace */ @@ -1095,10 +1114,12 @@ test_attr_mult_read() verify_val(rank, ATTR2_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Get the dims of the dataspace and verify them - ndims = space.getSimpleExtentDims(dims); + (void)space.getSimpleExtentDims(dims); - verify_val((long)dims[0], (long)ATTR2_DIM1, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - verify_val((long)dims[1], (long)ATTR2_DIM2, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val(static_cast(dims[0]), static_cast(ATTR2_DIM1), + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val(static_cast(dims[1]), static_cast(ATTR2_DIM2), + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); /* Verify Datatype */ @@ -1106,14 +1127,16 @@ test_attr_mult_read() type_class = attr.getTypeClass(); // Verify that the type is of integer datatype - verify_val(type_class, H5T_INTEGER, "Attribute::getTypeClass", __LINE__, __FILE__); + verify_val(static_cast(type_class), static_cast(H5T_INTEGER), "Attribute::getTypeClass", + __LINE__, __FILE__); // Get the integer datatype IntType i_type2 = attr.getIntType(); // Get and verify the order of this type order = i_type2.getOrder(); - verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__); + verify_val(static_cast(order), static_cast(PredType::NATIVE_INT.getOrder()), + "DataType::getOrder", __LINE__, __FILE__); // Get and verify the size of this type size = i_type2.getSize(); @@ -1138,7 +1161,7 @@ test_attr_mult_read() space.close(); // Open 3rd attribute for the dataset - attr = dataset.openAttribute((unsigned)2); + attr = dataset.openAttribute(static_cast(2)); /* Verify Dataspace */ @@ -1150,10 +1173,13 @@ test_attr_mult_read() verify_val(rank, ATTR3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Get the dims of the dataspace and verify them - ndims = space.getSimpleExtentDims(dims); - verify_val((long)dims[0], (long)ATTR3_DIM1, "attribute dimensions", __FILE__, __LINE__); - verify_val((long)dims[1], (long)ATTR3_DIM2, "attribute dimensions", __FILE__, __LINE__); - verify_val((long)dims[2], (long)ATTR3_DIM3, "attribute dimensions", __FILE__, __LINE__); + (void)space.getSimpleExtentDims(dims); + verify_val(static_cast(dims[0]), static_cast(ATTR3_DIM1), "attribute dimensions", + __FILE__, __LINE__); + verify_val(static_cast(dims[1]), static_cast(ATTR3_DIM2), "attribute dimensions", + __FILE__, __LINE__); + verify_val(static_cast(dims[2]), static_cast(ATTR3_DIM3), "attribute dimensions", + __FILE__, __LINE__); /* Verify Datatype */ @@ -1161,14 +1187,16 @@ test_attr_mult_read() type_class = attr.getTypeClass(); // Verify that the type is of compound datatype - verify_val(type_class, H5T_FLOAT, "Attribute::getTypeClass", __LINE__, __FILE__); + verify_val(static_cast(type_class), static_cast(H5T_FLOAT), "Attribute::getTypeClass", + __LINE__, __FILE__); // Get the double datatype FloatType f_type = attr.getFloatType(); // Get and verify the order of this type order = f_type.getOrder(); - verify_val(order, PredType::NATIVE_DOUBLE.getOrder(), "DataType::getOrder", __LINE__, __FILE__); + verify_val(static_cast(order), static_cast(PredType::NATIVE_DOUBLE.getOrder()), + "DataType::getOrder", __LINE__, __FILE__); // Get and verify the size of this type size = f_type.getSize(); @@ -1181,7 +1209,7 @@ test_attr_mult_read() for (i = 0; i < ATTR3_DIM1; i++) for (j = 0; j < ATTR3_DIM2; j++) for (k = 0; k < ATTR3_DIM3; k++) - if (attr_data3[i][j][k] != read_data3[i][j][k]) + if (abs(attr_data3[i][j][k] - read_data3[i][j][k]) > DBL_EPSILON) TestErrPrintf("%d: attribute data different: attr_data3[%llu][%llu][%llu]=%f, " "read_data3[%llu][%llu][%llu]=%f\n", __LINE__, i, j, k, attr_data3[i][j][k], i, j, k, read_data3[i][j][k]); @@ -1230,7 +1258,7 @@ test_attr_delete() verify_val(num_attrs, 1, "H5File::getNumAttrs", __LINE__, __FILE__); // Verify the name of the only file attribute left - Attribute fattr = fid1.openAttribute((unsigned)0); + Attribute fattr = fid1.openAttribute(static_cast(0)); attr_name = fattr.getName(); verify_val(attr_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); fattr.close(); @@ -1270,7 +1298,7 @@ test_attr_delete() verify_val(num_attrs, 2, "DataSet::getNumAttrs", __LINE__, __FILE__); // Open 1st attribute for the dataset - Attribute attr = dataset.openAttribute((unsigned)0); + Attribute attr = dataset.openAttribute(static_cast(0)); // Verify Name attr_name = attr.getName(); @@ -1280,7 +1308,7 @@ test_attr_delete() attr.close(); // Open last (formally 3rd) attribute for the dataset - attr = dataset.openAttribute((unsigned)1); + attr = dataset.openAttribute(static_cast(1)); // Verify Name attr_name = attr.getName(); @@ -1296,7 +1324,7 @@ test_attr_delete() verify_val(num_attrs, 1, "DataSet::getNumAttrs", __LINE__, __FILE__); // Open the only attribute for the dataset (formally 3rd) - attr = dataset.openAttribute((unsigned)0); + attr = dataset.openAttribute(static_cast(0)); // Verify Name attr_name = attr.getName(); @@ -1370,7 +1398,7 @@ test_attr_dtype_shared() #ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 1, "DataType::getObjinfo", __LINE__, __FILE__); + verify_val(static_cast(statbuf.nlink), 1, "DataType::getObjinfo", __LINE__, __FILE__); #endif // Create dataspace for dataset @@ -1381,7 +1409,7 @@ test_attr_dtype_shared() #ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 2, "H5File::getObjinfo", __LINE__, __FILE__); + verify_val(static_cast(statbuf.nlink), 2, "H5File::getObjinfo", __LINE__, __FILE__); #endif // Create attribute on dataset @@ -1390,7 +1418,7 @@ test_attr_dtype_shared() #ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__); + verify_val(static_cast(statbuf.nlink), 3, "DataSet::getObjinfo", __LINE__, __FILE__); #endif // Close attribute @@ -1402,8 +1430,8 @@ test_attr_dtype_shared() #ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__, - __FILE__); + verify_val(static_cast(statbuf.nlink), 2, "DataSet::getObjinfo after DataSet::removeAttr", + __LINE__, __FILE__); #endif // Create attribute on dataset @@ -1412,7 +1440,7 @@ test_attr_dtype_shared() #ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::createAttribute", __LINE__, __FILE__); + verify_val(static_cast(statbuf.nlink), 3, "DataSet::createAttribute", __LINE__, __FILE__); #endif // Write data into the attribute @@ -1449,7 +1477,7 @@ test_attr_dtype_shared() #ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__); + verify_val(static_cast(statbuf.nlink), 3, "DataSet::openAttribute", __LINE__, __FILE__); #endif } // end of second enclosing @@ -1459,7 +1487,7 @@ test_attr_dtype_shared() #ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 1, "H5File::unlink", __LINE__, __FILE__); + verify_val(static_cast(statbuf.nlink), 1, "H5File::unlink", __LINE__, __FILE__); #endif // Unlink the named datatype @@ -1470,7 +1498,8 @@ test_attr_dtype_shared() // Check size of file filesize = h5_get_file_size(FILE_DTYPE.c_str(), H5P_DEFAULT); - verify_val((long)filesize, (long)empty_filesize, "Checking file size", __LINE__, __FILE__); + verify_val(static_cast(filesize), static_cast(empty_filesize), "Checking file size", + __LINE__, __FILE__); PASSED(); } // end try block @@ -1806,7 +1835,8 @@ test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl) // Get creation order indexing on object unsigned crt_order_flags = 0; crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); + verify_val(static_cast(crt_order_flags), 0, "DSetCreatPropList::getAttrCrtOrder", __LINE__, + __FILE__); // Setting invalid combination of a attribute order creation order // indexing on should fail @@ -1825,7 +1855,7 @@ test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl) // verify them dcpl.setAttrCrtOrder(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), + verify_val(crt_order_flags, static_cast(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); // Create dataspace for dataset @@ -1861,7 +1891,7 @@ test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl) // Query the attribute creation properties crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), + verify_val(crt_order_flags, static_cast(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); PASSED(); diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index 2170a9d..c27171b 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -101,11 +101,11 @@ test_compound_2() SUBTEST("Compound Element Reordering"); try { // Sizes should be the same, but be careful just in case - buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + buf = static_cast(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)))); + bkg = static_cast(HDmalloc(nelmts * sizeof(dst_typ_t))); + orig = static_cast(HDmalloc(nelmts * sizeof(src_typ_t))); for (i = 0; i < nelmts; i++) { - s_ptr = ((src_typ_t *)orig) + i; + s_ptr = (reinterpret_cast(orig)) + i; s_ptr->a = i * 8 + 0; s_ptr->b = i * 8 + 1; s_ptr->c[0] = i * 8 + 2; @@ -115,7 +115,7 @@ test_compound_2() s_ptr->d = i * 8 + 6; s_ptr->e = i * 8 + 7; } - memcpy(buf, orig, nelmts * sizeof(src_typ_t)); + HDmemcpy(buf, orig, nelmts * sizeof(src_typ_t)); // Build hdf5 datatypes array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -142,12 +142,12 @@ test_compound_2() array_dt->close(); // Perform the conversion - st.convert(dt, (size_t)nelmts, buf, bkg); + st.convert(dt, static_cast(nelmts), buf, bkg); // Compare results for (i = 0; i < nelmts; i++) { - s_ptr = ((src_typ_t *)orig) + i; - d_ptr = ((dst_typ_t *)buf) + i; + s_ptr = (reinterpret_cast(orig)) + i; + d_ptr = (reinterpret_cast(buf)) + i; if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) { @@ -214,11 +214,11 @@ test_compound_3() SUBTEST("Compound Datatype Subset Conversions"); try { /* Initialize */ - buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + buf = static_cast(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)))); + bkg = static_cast(HDmalloc(nelmts * sizeof(dst_typ_t))); + orig = static_cast(HDmalloc(nelmts * sizeof(src_typ_t))); for (i = 0; i < nelmts; i++) { - s_ptr = ((src_typ_t *)orig) + i; + s_ptr = (reinterpret_cast(orig)) + i; s_ptr->a = i * 8 + 0; s_ptr->b = i * 8 + 1; s_ptr->c[0] = i * 8 + 2; @@ -253,12 +253,12 @@ test_compound_3() array_dt->close(); /* Perform the conversion */ - st.convert(dt, (size_t)nelmts, buf, bkg); + st.convert(dt, static_cast(nelmts), buf, bkg); /* Compare results */ for (i = 0; i < nelmts; i++) { - s_ptr = ((src_typ_t *)orig) + i; - d_ptr = ((dst_typ_t *)buf) + i; + s_ptr = (reinterpret_cast(orig)) + i; + d_ptr = (reinterpret_cast(buf)) + i; if (s_ptr->a != d_ptr->a || s_ptr->c[0] != d_ptr->c[0] || s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || s_ptr->e != d_ptr->e) { H5_FAILED(); @@ -268,8 +268,8 @@ test_compound_3() << ", e=" << s_ptr->e << "}" << endl; cerr << " dst={a=" << d_ptr->a << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," << d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" << d_ptr->e << "}" << endl; - } // if - } // for + } + } /* Release resources */ HDfree(buf); @@ -329,11 +329,11 @@ test_compound_4() SUBTEST("Compound Element Shrinking & Reordering"); try { /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + buf = static_cast(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)))); + bkg = static_cast(HDmalloc(nelmts * sizeof(dst_typ_t))); + orig = static_cast(HDmalloc(nelmts * sizeof(src_typ_t))); for (i = 0; i < nelmts; i++) { - s_ptr = ((src_typ_t *)orig) + i; + s_ptr = (reinterpret_cast(orig)) + i; s_ptr->a = i * 8 + 0; s_ptr->b = (i * 8 + 1) & 0x7fff; s_ptr->c[0] = i * 8 + 2; @@ -370,12 +370,12 @@ test_compound_4() array_dt->close(); /* Perform the conversion */ - st.convert(dt, (size_t)nelmts, buf, bkg); + st.convert(dt, static_cast(nelmts), buf, bkg); /* Compare results */ for (i = 0; i < nelmts; i++) { - s_ptr = ((src_typ_t *)orig) + i; - d_ptr = ((dst_typ_t *)buf) + i; + s_ptr = (reinterpret_cast(orig)) + i; + d_ptr = (reinterpret_cast(buf)) + i; if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) { @@ -473,8 +473,8 @@ test_compound_5() /* Convert data */ memcpy(buf, src, sizeof(src)); - src_type.convert(dst_type, (size_t)2, buf, bkg); - dst = (dst_typ_t *)buf; + src_type.convert(dst_type, 2, buf, bkg); + dst = static_cast(buf); /* Cleanup */ src_type.close(); @@ -540,11 +540,11 @@ test_compound_6() SUBTEST("Compound Element Growing"); try { /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + buf = static_cast(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)))); + bkg = static_cast(HDmalloc(nelmts * sizeof(dst_typ_t))); + orig = static_cast(HDmalloc(nelmts * sizeof(src_typ_t))); for (i = 0; i < nelmts; i++) { - s_ptr = ((src_typ_t *)orig) + i; + s_ptr = (reinterpret_cast(orig)) + i; s_ptr->b = (i * 8 + 1) & 0x7fff; s_ptr->d = (i * 8 + 6) & 0x7fff; } @@ -560,19 +560,19 @@ test_compound_6() dt.insertMember("d", HOFFSET(dst_typ_t, d), PredType::NATIVE_LONG); /* Perform the conversion */ - st.convert(dt, (size_t)nelmts, buf, bkg); + st.convert(dt, static_cast(nelmts), buf, bkg); /* Compare results */ for (i = 0; i < nelmts; i++) { - s_ptr = ((src_typ_t *)orig) + i; - d_ptr = ((dst_typ_t *)buf) + i; + s_ptr = (reinterpret_cast(orig)) + i; + d_ptr = (reinterpret_cast(buf)) + i; if (s_ptr->b != d_ptr->b || s_ptr->d != d_ptr->d) { H5_FAILED(); cerr << " i=" << i << endl; cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d << "}" << endl; cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d << "}" << endl; - } // if - } // for + } + } /* Release resources */ HDfree(buf); @@ -715,22 +715,22 @@ test_compound_set_size() // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); // Expand the type, and verify that it became unpacked - dtype.setSize((size_t)33); + dtype.setSize(33); // packed = dtype.packed(); // not until C library provides API // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); // Verify setSize() actually set size size_t new_size = dtype.getSize(); - verify_val(new_size, (size_t)33, "DataType::getSize", __LINE__, __FILE__); + verify_val(static_cast(new_size), 33, "DataType::getSize", __LINE__, __FILE__); // Shrink the type, and verify that it became packed - dtype.setSize((size_t)32); + dtype.setSize(32); // packed = dtype.packed(); // not until C library provides API // verify_val(packed, TRUE, "DataType::packed", __LINE__, __FILE__); // Verify setSize() actually set size again new_size = dtype.getSize(); - verify_val(new_size, (size_t)32, "DataType::getSize", __LINE__, __FILE__); + verify_val(static_cast(new_size), 32, "DataType::getSize", __LINE__, __FILE__); /* Close types and file */ dtype_tmp.close(); diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp index 257233e..5a78133 100644 --- a/c++/test/tdspl.cpp +++ b/c++/test/tdspl.cpp @@ -61,11 +61,11 @@ test_transfplist() // Find out the length of the transform expression, allocate the buffer // for it, then read and verify the expression from the copied plist ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL); - char * c_to_f_read = (char *)HDmalloc(tran_len + 1); + char * c_to_f_read = static_cast(HDmalloc(tran_len + 1)); HDmemset(c_to_f_read, 0, tran_len + 1); dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len + 1); - verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform", - __LINE__, __FILE__); + verify_val(const_cast(c_to_f_read), const_cast(c_to_f), + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); HDfree(c_to_f_read); // @@ -76,26 +76,26 @@ test_transfplist() // Get and verify the expression with: // ssize_t getDataTransform(char* exp, const size_t buf_size [default=0]) tran_len = dxpl_c_to_f.getDataTransform(NULL); - c_to_f_read = (char *)HDmalloc(tran_len + 1); + c_to_f_read = static_cast(HDmalloc(tran_len + 1)); HDmemset(c_to_f_read, 0, tran_len + 1); dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len + 1); - verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform", - __LINE__, __FILE__); + verify_val(const_cast(c_to_f_read), const_cast(c_to_f), + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); HDfree(c_to_f_read); // Get and verify the expression with: // H5std_string DSetMemXferPropList::getDataTransform() H5std_string simple_read = dxpl_simple.getDataTransform(); - verify_val((const char *)simple_read.c_str(), (const char *)simple, + verify_val(const_cast(simple_read.c_str()), const_cast(simple), "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); // Get and verify the expression with: // ssize_t getDataTransform(char* exp, const size_t buf_size) tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0); - char *utrans_inv_read = (char *)HDmalloc(tran_len + 1); + char *utrans_inv_read = static_cast(HDmalloc(tran_len + 1)); HDmemset(utrans_inv_read, 0, tran_len + 1); dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len + 1); - verify_val((const char *)utrans_inv_read, (const char *)utrans_inv, + verify_val(const_cast(utrans_inv_read), const_cast(utrans_inv), "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); HDfree(utrans_inv_read); diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index 255fc30..15bad64 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -31,14 +31,14 @@ using namespace H5; #include "h5test.h" #include "h5cpputil.h" // C++ utilility header file -const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0; +const hsize_t F1_USERBLOCK_SIZE = 0; const size_t F1_OFFSET_SIZE = sizeof(haddr_t); const size_t F1_LENGTH_SIZE = sizeof(hsize_t); const unsigned F1_SYM_LEAF_K = 4; const unsigned F1_SYM_INTERN_K = 16; const H5std_string FILE1("tfile1.h5"); -const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512; +const hsize_t F2_USERBLOCK_SIZE = 512; const size_t F2_OFFSET_SIZE = 8; const size_t F2_LENGTH_SIZE = 8; const unsigned F2_SYM_LEAF_K = 8; @@ -46,7 +46,7 @@ const unsigned F2_SYM_INTERN_K = 32; const unsigned F2_ISTORE = 64; const H5std_string FILE2("tfile2.h5"); -const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0; +const hsize_t F3_USERBLOCK_SIZE = 0; const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE; const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE; const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K; @@ -153,8 +153,8 @@ test_file_create() FileCreatPropList tmpl1 = file1->getCreatePlist(); hsize_t ublock = tmpl1.getUserblock(); - verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, - __FILE__); + verify_val(static_cast(ublock), static_cast(F1_USERBLOCK_SIZE), + "FileCreatPropList::getUserblock", __LINE__, __FILE__); size_t parm1, parm2; // file-creation parameters tmpl1.getSizes(parm1, parm2); @@ -209,8 +209,8 @@ test_file_create() // Get the file-creation parameters hsize_t ublock = tmpl1->getUserblock(); - verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, - __FILE__); + verify_val(static_cast(ublock), static_cast(F2_USERBLOCK_SIZE), + "FileCreatPropList::getUserblock", __LINE__, __FILE__); size_t parm1, parm2; // file-creation parameters tmpl1->getSizes(parm1, parm2); @@ -242,8 +242,8 @@ test_file_create() // Get the file-creation parameters ublock = tmpl1->getUserblock(); - verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, - __FILE__); + verify_val(static_cast(ublock), static_cast(F3_USERBLOCK_SIZE), + "FileCreatPropList::getUserblock", __LINE__, __FILE__); tmpl1->getSizes(parm1, parm2); verify_val(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); @@ -300,8 +300,8 @@ test_file_open() // Get the file-creation parameters hsize_t ublock = tmpl1.getUserblock(); - verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, - __FILE__); + verify_val(static_cast(ublock), static_cast(F2_USERBLOCK_SIZE), + "FileCreatPropList::getUserblock", __LINE__, __FILE__); size_t parm1, parm2; // file-creation parameters tmpl1.getSizes(parm1, parm2); @@ -645,7 +645,8 @@ test_file_attribute() // Get the class of a file attribute's datatype H5T_class_t atclass = fattr1.getTypeClass(); - verify_val(atclass, H5T_FLOAT, "Attribute::getTypeClass()", __LINE__, __FILE__); + verify_val(static_cast(atclass), static_cast(H5T_FLOAT), "Attribute::getTypeClass()", + __LINE__, __FILE__); // Get and verify the number of attributes attached to a file int n_attrs = file5.getNumAttrs(); @@ -896,9 +897,9 @@ test_file_info() // Get the file's version information. H5F_info2_t finfo; tempfile.getFileInfo(finfo); - verify_val(finfo.super.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(finfo.super.version), 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(finfo.free.version), 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(finfo.sohm.version), 0, "H5File::getFileInfo", __LINE__, __FILE__); // Close the file. tempfile.close(); @@ -910,9 +911,10 @@ test_file_info() fcpl.getFileSpaceStrategy(out_strategy, out_persist, out_threshold); // Verify file space information. - verify_val(out_strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(out_strategy), static_cast(H5F_FSPACE_STRATEGY_FSM_AGGR), + "H5File::getFileInfo", __LINE__, __FILE__); verify_val(out_persist, FALSE, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(out_threshold, 1, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(out_threshold), 1, "H5File::getFileInfo", __LINE__, __FILE__); /* Retrieve file space page size */ hsize_t out_fsp_psize = fcpl.getFileSpacePagesize(); @@ -943,9 +945,9 @@ test_file_info() // Get the file's version information. file7.getFileInfo(finfo); - verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(finfo.super.version), 2, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(finfo.free.version), 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(finfo.sohm.version), 0, "H5File::getFileInfo", __LINE__, __FILE__); // Close the file. file7.close(); @@ -958,9 +960,9 @@ test_file_info() // Get the file's version information. file7.getFileInfo(finfo); - verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(finfo.super.version), 2, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(finfo.free.version), 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(static_cast(finfo.sohm.version), 0, "H5File::getFileInfo", __LINE__, __FILE__); // Retrieve the property values & check them. hsize_t userblock = fcpl2.getUserblock(); @@ -986,7 +988,8 @@ test_file_info() // Get and verify the file space info from the creation property list */ fcpl2.getFileSpaceStrategy(out_strategy, out_persist, out_threshold); - verify_val(out_strategy, strategy, "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); + verify_val(static_cast(out_strategy), static_cast(strategy), + "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); verify_val(out_persist, persist, "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); verify_val(out_threshold, threshold, "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index 9952e68..5808136 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -73,7 +73,7 @@ struct space4_struct { unsigned u; float f; char c2; -} space4_data = {'v', 987123, (float)-3.14, 'g'}; /* Test data for 4th dataspace */ +} space4_data = {'v', 987123, -3.14f, 'g'}; /* Test data for 4th dataspace */ /* Null dataspace */ int space5_data = 7; @@ -118,7 +118,7 @@ test_h5s_basic() // Get simple extent npoints of the dataspace sid1 and verify it hssize_t n; // Number of dataspace elements n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, (long)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3), + verify_val(static_cast(n), SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of dataspace sid1 and verify it @@ -140,7 +140,7 @@ test_h5s_basic() // Get simple extent npoints of dataspace sid2 and verify it n = sid2.getSimpleExtentNpoints(); - verify_val((long)n, (long)(SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4), + verify_val(static_cast(n), SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of dataspace sid2 and verify it @@ -200,6 +200,7 @@ test_h5s_basic() // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure // in the p_close see how this will handle it. - BMR + // When running in valgrind, this PASSED macro will be missed PASSED(); } // end of try block @@ -248,7 +249,7 @@ test_h5s_scalar_write() // n = H5Sget_simple_extent_npoints(sid1); hssize_t n; // Number of dataspace elements n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + verify_val(static_cast(n), 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); int rank; // Logical rank of dataspace rank = sid1.getSimpleExtentNdims(); @@ -263,7 +264,8 @@ test_h5s_scalar_write() // Verify extent type H5S_class_t ext_type; // Extent type ext_type = sid1.getSimpleExtentType(); - verify_val(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__); + verify_val(static_cast(ext_type), static_cast(H5S_SCALAR), + "DataSpace::getSimpleExtentType", __LINE__, __FILE__); // Create and write a dataset DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1); @@ -314,7 +316,7 @@ test_h5s_scalar_read() // Get the number of dataspace elements hssize_t n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + verify_val(static_cast(n), 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of the dataspace int ndims = sid1.getSimpleExtentNdims(); @@ -371,7 +373,7 @@ test_h5s_null() hssize_t n; // Number of dataspace elements n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, 0, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + verify_val(static_cast(n), 0, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Create a dataset DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1); @@ -436,7 +438,7 @@ test_h5s_compound_scalar_write() // Get the number of dataspace elements hssize_t n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + verify_val(static_cast(n), 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of the dataspace int ndims = sid1.getSimpleExtentNdims(); @@ -496,7 +498,7 @@ test_h5s_compound_scalar_read() // Get the number of dataspace elements hssize_t n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + verify_val(static_cast(n), 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of the dataspace int ndims = sid1.getSimpleExtentNdims(); diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp index 17620ca..b6a9436 100644 --- a/c++/test/titerate.cpp +++ b/c++/test/titerate.cpp @@ -67,7 +67,8 @@ typedef struct { iter_enum command; /* The type of return value */ } iter_info; -int iter_strcmp(const void *s1, const void *s2); +static int iter_strcmp(const void *s1, const void *s2); +static void printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname); /*------------------------------------------------------------------------- * Function: iter_strcmp @@ -75,10 +76,10 @@ int iter_strcmp(const void *s1, const void *s2); * Purpose String comparison routine for qsort *------------------------------------------------------------------------- */ -int +static int iter_strcmp(const void *s1, const void *s2) { - return (HDstrcmp(*(const char *const *)s1, *(const char *const *)s2)); + return (HDstrcmp(*reinterpret_cast(s1), *reinterpret_cast(s2))); } /*------------------------------------------------------------------------- @@ -91,7 +92,7 @@ static herr_t liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info, void *op_data) { - iter_info *info = (iter_info *)op_data; + iter_info *info = static_cast(op_data); static int count = 0; static int count2 = 0; @@ -133,7 +134,6 @@ liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR static void test_iter_group(FileAccPropList &fapl) { - int i; /* counting variable */ hsize_t idx; /* Index in the group */ char name[NAMELEN]; /* temporary name buffer */ char * lnames[NDATASETS + 2]; /* Names of the links created */ @@ -159,7 +159,7 @@ test_iter_group(FileAccPropList &fapl) // Create a scalar file space DataSpace filespace; - for (i = 0; i < NDATASETS; i++) { + for (int i = 0; i < NDATASETS; i++) { sprintf(name, "Dataset %d", i); // Create a dataset in the file @@ -168,8 +168,7 @@ test_iter_group(FileAccPropList &fapl) /* Keep a copy of the dataset names */ lnames[i] = HDstrdup(name); check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__); - - } /* end for */ + } /* Create a group and named datatype under root group for testing */ Group grp(file.createGroup(GROUP1, 0)); @@ -181,7 +180,7 @@ test_iter_group(FileAccPropList &fapl) check_values(lnames[NDATASETS], "HDstrdup returns NULL", __LINE__, __FILE__); /* Sort the dataset names */ - HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp); + HDqsort(lnames, NDATASETS + 2, sizeof(char *), iter_strcmp); /* Iterate through the datasets in the root group in various ways */ @@ -193,10 +192,10 @@ test_iter_group(FileAccPropList &fapl) // Get the number of object in the root group hsize_t nobjs = root_group.getNumObjs(); - verify_val(nobjs, (hsize_t)(NDATASETS + 2), "H5Gget_info", __LINE__, __FILE__); + verify_val(static_cast(nobjs), NDATASETS + 2, "H5Gget_info", __LINE__, __FILE__); H5std_string obj_name; - for (i = 0; i < nobjs; i++) { + for (hsize_t i = 0; i < nobjs; i++) { // H5O_info2_t oinfo; /* Object info */ obj_name = root_group.getObjnameByIdx(i); @@ -206,7 +205,7 @@ test_iter_group(FileAccPropList &fapl) // oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, "."); // ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, // H5P_DEFAULT); - } /* end for */ + } // Attempted to iterate with invalid index, should fail try { @@ -222,7 +221,7 @@ test_iter_group(FileAccPropList &fapl) // Attempted to iterate with negative index, should fail try { info.command = RET_ZERO; - idx = (hsize_t)-1; + idx = HSIZE_UNDEF; obj_name = root_group.getObjnameByIdx(idx); // Should FAIL but didn't, so throw an invalid action exception @@ -268,7 +267,7 @@ test_iter_group(FileAccPropList &fapl) } // do nothing, exception expected /* Free the dataset names */ - for (i = 0; i < (NDATASETS + 2); i++) + for (int i = 0; i < NDATASETS + 2; i++) HDfree(lnames[i]); // Everything will be closed as they go out of scope @@ -360,7 +359,7 @@ const H5std_string ATTR_NAME("Units"); const H5std_string FATTR_NAME("F attr"); const H5std_string GATTR_NAME("G attr"); const int DIM1 = 2; -void +static void printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname) { try { diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index e8dad5b..8c7f0cd 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -201,7 +201,8 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) // Check that its character encoding is the default. linfo = file.getLinkInfo("/type"); - verify_val(linfo.cset, H5T_CSET_ASCII, "Character encoding is not default", __LINE__, __FILE__); + verify_val(static_cast(linfo.cset), static_cast(H5T_CSET_ASCII), + "Character encoding is not default", __LINE__, __FILE__); // Create a simple dataspace. dims[0] = H5L_DIM1; @@ -214,7 +215,8 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) // Check that its character encoding is the default. linfo = file.getLinkInfo("/dataset"); - verify_val(linfo.cset, H5T_CSET_ASCII, "Character encoding is not default", __LINE__, __FILE__); + verify_val(static_cast(linfo.cset), static_cast(H5T_CSET_ASCII), + "Character encoding is not default", __LINE__, __FILE__); // Create a link creation property list with the UTF-8 character encoding. LinkCreatPropList lcpl; @@ -226,7 +228,8 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) // Check that its character encoding is UTF-8. linfo = file.getLinkInfo(GROUP2NAME); - verify_val(linfo.cset, H5T_CSET_UTF8, "Character encoding is not UTF-8", __LINE__, __FILE__); + verify_val(static_cast(linfo.cset), static_cast(H5T_CSET_UTF8), + "Character encoding is not UTF-8", __LINE__, __FILE__); PASSED(); } // end of try block @@ -580,12 +583,13 @@ const H5std_string GROUP_NAME("/Data"); const H5std_string DSET1_NAME("/Data/Compressed_Data"); const H5std_string DSET2_NAME("/Data/Float_Data"); const int RANK = 2; -const int DIM1 = 2; // Operator function static int visit_obj_cb(H5Object &obj, const H5std_string name, const H5O_info2_t *oinfo, void *_op_data) { + (void)obj; // Unused + ovisit_ud_t *op_data = static_cast(_op_data); // Check for correct object information diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index 5892f39..2b694da 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -87,7 +87,7 @@ test_get_objname() if (name_len > 4) { char *grp1_name = new char[5]; name_len = grp1.getObjName(grp1_name, 5); - verify_val((const char *)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__); + verify_val(const_cast(grp1_name), "/Top", "Group::getObjName", __LINE__, __FILE__); delete[] grp1_name; } @@ -317,8 +317,8 @@ test_get_objname_ontypes() // Name this datatype new_int_type.commit(grp, "IntType NATIVE_INT"); ssize_t name_len = new_int_type.getObjName(type_name); // default len - verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", - __LINE__, __FILE__); + verify_val(name_len, static_cast(HDstrlen("/typetests/IntType NATIVE_INT")), + "DataType::getObjName", __LINE__, __FILE__); verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataType::getObjName", __LINE__, __FILE__); // Close everything or they can be closed when objects go out of scope @@ -366,25 +366,29 @@ test_get_objtype() // Get and verify object type with // H5O_type_t childObjType(const H5std_string& objname) H5O_type_t objtype = file.childObjType(DSET_IN_FILE); - verify_val(objtype, H5O_TYPE_DATASET, "DataSet::childObjType", __LINE__, __FILE__); + verify_val(static_cast(objtype), static_cast(H5O_TYPE_DATASET), "DataSet::childObjType", + __LINE__, __FILE__); // Get and verify object type with // H5O_type_t childObjType(const char* objname) objtype = grp1.childObjType(GROUP1_1.c_str()); - verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__); + verify_val(static_cast(objtype), static_cast(H5O_TYPE_GROUP), "DataSet::childObjType", + __LINE__, __FILE__); // Get and verify object type with // H5O_type_t childObjType(hsize_t index, H5_index_t index_type, // H5_iter_order_t order, const char* objname=".") - objtype = grp1.childObjType((hsize_t)1, H5_INDEX_NAME, H5_ITER_INC); - verify_val(objtype, H5O_TYPE_NAMED_DATATYPE, "DataSet::childObjType", __LINE__, __FILE__); + objtype = grp1.childObjType(1, H5_INDEX_NAME, H5_ITER_INC); + verify_val(static_cast(objtype), static_cast(H5O_TYPE_NAMED_DATATYPE), + "DataSet::childObjType", __LINE__, __FILE__); // Get and verify object type with // H5O_type_t childObjType(hsize_t index, // H5_index_t index_type=H5_INDEX_NAME, // H5_iter_order_t order=H5_ITER_INC, const char* objname=".") - objtype = grp1.childObjType((hsize_t)2); - verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__); + objtype = grp1.childObjType(2); + verify_val(static_cast(objtype), static_cast(H5O_TYPE_GROUP), "DataSet::childObjType", + __LINE__, __FILE__); // Everything will be closed as they go out of scope @@ -455,17 +459,20 @@ test_open_object_header() // Make sure that each is the right kind of ID H5I_type_t id_type = IdComponent::getHDFObjType(obj_grp); - verify_val(id_type, H5I_GROUP, "H5Iget_type for group ID", __LINE__, __FILE__); + verify_val(static_cast(id_type), static_cast(H5I_GROUP), "H5Iget_type for group ID", + __LINE__, __FILE__); id_type = IdComponent::getHDFObjType(obj_dtype); - verify_val(id_type, H5I_DATATYPE, "H5Iget_type for datatype ID", __LINE__, __FILE__); + verify_val(static_cast(id_type), static_cast(H5I_DATATYPE), "H5Iget_type for datatype ID", + __LINE__, __FILE__); id_type = IdComponent::getHDFObjType(obj_dset); - verify_val(id_type, H5I_DATASET, "H5Iget_type for dataset ID", __LINE__, __FILE__); + verify_val(static_cast(id_type), static_cast(H5I_DATASET), "H5Iget_type for dataset ID", + __LINE__, __FILE__); /* Do something more complex with each of the IDs to make sure */ Group grp2(obj_grp); hsize_t num_objs = grp2.getNumObjs(); - verify_val(num_objs, 1, "H5Gget_info", __LINE__, __FILE__); + verify_val(static_cast(num_objs), 1, "H5Gget_info", __LINE__, __FILE__); // There should be one object, the datatype // Close datatype object opened from the file @@ -482,7 +489,8 @@ test_open_object_header() dtype.setId(obj_dtype); H5T_class_t type_class = dtype.getClass(); - verify_val(type_class, H5T_INTEGER, "H5Tget_class", __LINE__, __FILE__); + verify_val(static_cast(type_class), static_cast(H5T_INTEGER), "H5Tget_class", __LINE__, + __FILE__); dtype.close(); // Close datatype object @@ -493,7 +501,7 @@ test_open_object_header() // Try doing something with group, the ID should still work num_objs = grp2.getNumObjs(); - verify_val(num_objs, 1, "H5Gget_info", __LINE__, __FILE__); + verify_val(static_cast(num_objs), 1, "H5Gget_info", __LINE__, __FILE__); // Close the cloned group grp2.close(); diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index 604ccc0..53a4ed3 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -81,9 +81,9 @@ test_reference_params() // Allocate write & read buffers int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t)); - wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); - rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); - tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + wbuf = static_cast(HDmalloc(temp_size * SPACE1_DIM1)); + rbuf = static_cast(HDmalloc(temp_size * SPACE1_DIM1)); + tbuf = static_cast(HDmalloc(temp_size * SPACE1_DIM1)); // Create file FILE1 file1 = new H5File(FILE1, H5F_ACC_TRUNC); @@ -103,7 +103,7 @@ test_reference_params() unsigned *tu32; // Temporary pointer to uint32 data int i; - for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) + for (tu32 = reinterpret_cast(wbuf), i = 0; i < SPACE1_DIM1; i++) *tu32++ = i * 3; // from C test // Write selection to disk @@ -208,9 +208,9 @@ test_reference_obj() // Allocate write & read buffers int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t)); - wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); - rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); - tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + wbuf = static_cast(HDmalloc(temp_size * SPACE1_DIM1)); + rbuf = static_cast(HDmalloc(temp_size * SPACE1_DIM1)); + tbuf = static_cast(HDmalloc(temp_size * SPACE1_DIM1)); // Create file FILE1 file1 = new H5File(FILE1, H5F_ACC_TRUNC); @@ -232,7 +232,7 @@ test_reference_obj() DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); unsigned *tu32; // Temporary pointer to uint32 data - for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) + for (tu32 = reinterpret_cast(wbuf), i = 0; i < SPACE1_DIM1; i++) *tu32++ = i * 3; // from C test // Write selection to disk @@ -268,22 +268,26 @@ test_reference_obj() // Create reference to dataset and test getRefObjType file1->reference(&wbuf[0], "/Group1/Dataset1"); H5O_type_t refobj_type = dataset.getRefObjType(&wbuf[0], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); + verify_val(static_cast(refobj_type), static_cast(H5O_TYPE_DATASET), + "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to dataset and test getRefObjType file1->reference(&wbuf[1], "/Group1/Dataset2"); refobj_type = dataset.getRefObjType(&wbuf[1], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); + verify_val(static_cast(refobj_type), static_cast(H5O_TYPE_DATASET), + "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to group file1->reference(&wbuf[2], "/Group1"); refobj_type = dataset.getRefObjType(&wbuf[2], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType", __LINE__, __FILE__); + verify_val(static_cast(refobj_type), static_cast(H5O_TYPE_GROUP), + "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to named datatype file1->reference(&wbuf[3], "/Group1/Datatype1"); refobj_type = dataset.getRefObjType(&wbuf[3], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType", __LINE__, __FILE__); + verify_val(static_cast(refobj_type), static_cast(H5O_TYPE_NAMED_DATATYPE), + "DataSet::getRefObjType", __LINE__, __FILE__); // Write selection to disk dataset.write(wbuf, PredType::STD_REF_OBJ); @@ -309,13 +313,14 @@ test_reference_obj() // Check information in the referenced dataset sid1 = dset2.getSpace(); hssize_t n_elements = sid1.getSimpleExtentNpoints(); - verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + verify_val(static_cast(n_elements), 4, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Read from disk dset2.read(tbuf, PredType::NATIVE_UINT); - for (tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - verify_val(*tu32, (uint32_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + for (tu32 = reinterpret_cast(tbuf), i = 0; i < SPACE1_DIM1; i++, tu32++) + verify_val(*tu32, static_cast(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, + __FILE__); // Close dereferenced dataset dset2.close(); @@ -353,7 +358,8 @@ test_reference_obj() H5T_class_t tclass; tclass = dtype1.getClass(); - verify_val(tclass, H5T_COMPOUND, "DataType::getClass", __LINE__, __FILE__); + verify_val(static_cast(tclass), static_cast(H5T_COMPOUND), "DataType::getClass", __LINE__, + __FILE__); int n_members = dtype1.getNmembers(); verify_val(n_members, 3, "CompType::getNmembers", __LINE__, __FILE__); @@ -468,11 +474,11 @@ test_reference_group() // Check number of objects in the group dereferenced by constructor hsize_t nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__); + verify_val(static_cast(nobjs), 3, "H5Group::getNumObjs", __LINE__, __FILE__); // Check number of objects in the group dereferenced by ::reference nobjs = group.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__); + verify_val(static_cast(nobjs), 3, "H5Group::getNumObjs", __LINE__, __FILE__); // Check getting file name given the group dereferenced via constructor H5std_string fname = refgroup.getFileName(); @@ -485,13 +491,14 @@ test_reference_group() // Check object type using Group::getObjinfo() H5O_info2_t oinfo; HDmemset(&oinfo, 0, sizeof(oinfo)); - group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, oinfo); - verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getObjinfo", __LINE__, __FILE__); + group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, 0, oinfo); + verify_val(static_cast(oinfo.type), static_cast(H5O_TYPE_DATASET), "Group::getObjinfo", + __LINE__, __FILE__); // Check for out of bound query by index try { HDmemset(&oinfo, 0, sizeof(oinfo)); - group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)9, oinfo); + group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, 9, oinfo); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjinfo", "Out of bound index."); @@ -502,7 +509,7 @@ test_reference_group() // Unlink one of the objects in the dereferenced group, and re-check refgroup.unlink(GROUPNAME2); nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs", __LINE__, __FILE__); + verify_val(static_cast(nobjs), 2, "H5Group::getNumObjs", __LINE__, __FILE__); // Close resources group.close(); @@ -550,10 +557,10 @@ test_reference_region_1D() *drbuf; // Buffer for reading numeric data from disk // Allocate write & read buffers - wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); - rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); - dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1); - drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); + wbuf = static_cast(HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1)); + rbuf = static_cast(HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1)); + dwbuf = static_cast(HDmalloc(sizeof(uint8_t) * SPACE3_DIM1)); + drbuf = static_cast(HDcalloc(sizeof(uint8_t), SPACE3_DIM1)); // Create file FILE1 H5File file1(FILE2, H5F_ACC_TRUNC); @@ -570,7 +577,7 @@ test_reference_region_1D() uint8_t *tu8; // Temporary pointer to uint8 data for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) - *tu8++ = i * 3; // from C test + *tu8++ = static_cast(i); // from C test // Write selection to disk dset3.write(dwbuf, PredType::STD_U8LE); @@ -607,7 +614,8 @@ test_reference_region_1D() // Get and verify object type H5O_type_t obj_type = dset1.getRefObjType(&wbuf[0], H5R_DATASET_REGION); - verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); + verify_val(static_cast(obj_type), static_cast(H5O_TYPE_DATASET), "DataSet::getRefObjType", + __LINE__, __FILE__); /* Select sequence of ten points for second reference */ coord1[0][0] = 16; @@ -622,7 +630,7 @@ test_reference_region_1D() coord1[9][0] = 3; // Selects array elements to be included in the selection for sid3 - sid3.selectElements(H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + sid3.selectElements(H5S_SELECT_SET, POINT1_NPOINTS, reinterpret_cast(coord1)); // Get and verify the number of elements in a dataspace selection nelms = sid3.getSelectNpoints(); @@ -658,12 +666,14 @@ test_reference_region_1D() // Get and verify object type obj_type = dset1.getRefObjType(&rbuf[0], H5R_DATASET_REGION); - verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); + verify_val(static_cast(obj_type), static_cast(H5O_TYPE_DATASET), + "DataSet::getRefObjType", __LINE__, __FILE__); // Get dataspace of dset3 the verify number of elements sid1 = dset3.getSpace(); nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + verify_val(static_cast(nelms), 100, "DataSpace::getSimpleExtentNpoints", __LINE__, + __FILE__); } // End of test DataSet::dereference { // Test DataSet constructor -by dereference @@ -674,7 +684,8 @@ test_reference_region_1D() // Get dataspace of newds then verify number of elements sid1 = newds.getSpace(); nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + verify_val(static_cast(nelms), 100, "DataSpace::getSimpleExtentNpoints", __LINE__, + __FILE__); // Close objects for this mini test newds.close(); @@ -684,8 +695,9 @@ test_reference_region_1D() // Read from disk dset3.read(drbuf, PredType::STD_U8LE); - for (tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) - verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + for (tu8 = static_cast(drbuf), i = 0; i < SPACE3_DIM1; i++, tu8++) + verify_val(*tu8, static_cast(i), "DataSpace::getSimpleExtentNpoints", __LINE__, + __FILE__); /* * Test getting the referenced region @@ -696,56 +708,56 @@ test_reference_region_1D() // Get and verify number of elements in a dataspace selection nelms = reg_sp.getSelectNpoints(); - verify_val((long)nelms, 30, "DataSpace::getSelectNpoints", __LINE__, __FILE__); + verify_val(static_cast(nelms), 30, "DataSpace::getSelectNpoints", __LINE__, __FILE__); // Get and verify number of hyperslab blocks nelms = reg_sp.getSelectHyperNblocks(); - verify_val((long)nelms, 15, "DataSpace::getSelectNpoints", __LINE__, __FILE__); + verify_val(static_cast(nelms), 15, "DataSpace::getSelectNpoints", __LINE__, __FILE__); /* Allocate space for the hyperslab blocks */ - coords = (hsize_t *)HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2); + coords = static_cast(HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2)); // Get the list of hyperslab blocks currently selected - reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords); + reg_sp.getSelectHyperBlocklist(0, static_cast(nelms), coords); // Verify values in the list - verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[4], (hsize_t)12, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[5], (hsize_t)13, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[6], (hsize_t)17, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[7], (hsize_t)18, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[8], (hsize_t)22, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[9], (hsize_t)23, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[10], (hsize_t)27, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[11], (hsize_t)28, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[12], (hsize_t)32, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[13], (hsize_t)33, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[14], (hsize_t)37, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[15], (hsize_t)38, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[16], (hsize_t)42, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[17], (hsize_t)43, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[18], (hsize_t)47, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[19], (hsize_t)48, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[20], (hsize_t)52, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[21], (hsize_t)53, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[22], (hsize_t)57, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[23], (hsize_t)58, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[24], (hsize_t)62, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[25], (hsize_t)63, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[26], (hsize_t)67, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[27], (hsize_t)68, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[28], (hsize_t)72, "Hyperslab Coordinates", __LINE__, __FILE__); - verify_val(coords[29], (hsize_t)73, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[0]), 2, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[1]), 3, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[2]), 7, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[3]), 8, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[4]), 12, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[5]), 13, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[6]), 17, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[7]), 18, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[8]), 22, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[9]), 23, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[10]), 27, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[11]), 28, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[12]), 32, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[13]), 33, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[14]), 37, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[15]), 38, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[16]), 42, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[17]), 43, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[18]), 47, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[19]), 48, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[20]), 52, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[21]), 53, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[22]), 57, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[23]), 58, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[24]), 62, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[25]), 63, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[26]), 67, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[27]), 68, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[28]), 72, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(static_cast(coords[29]), 73, "Hyperslab Coordinates", __LINE__, __FILE__); HDfree(coords); // Check boundaries reg_sp.getSelectBounds(low, high); - verify_val(low[0], (hsize_t)2, "DataSpace::getSelectBounds", __LINE__, __FILE__); - verify_val(high[0], (hsize_t)73, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(static_cast(low[0]), 2, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(static_cast(high[0]), 73, "DataSpace::getSelectBounds", __LINE__, __FILE__); /* Close region space */ reg_sp.close(); @@ -759,13 +771,13 @@ test_reference_region_1D() // Get and verify number of element points in the current selection hssize_t nelmspts = elm_sp.getSelectElemNpoints(); - verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints", __LINE__, __FILE__); + verify_val(static_cast(nelmspts), 10, "DataSpace::getSelectNpoints", __LINE__, __FILE__); /* Allocate space for the hyperslab blocks */ - coords = (hsize_t *)HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t)); + coords = static_cast(HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t))); // Get the list of element points currently selected - elm_sp.getSelectElemPointlist((hsize_t)0, (hsize_t)nelmspts, coords); + elm_sp.getSelectElemPointlist(0, static_cast(nelmspts), coords); // Verify points verify_val(coords[0], coord1[0][0], "Element Coordinates", __LINE__, __FILE__); @@ -783,8 +795,8 @@ test_reference_region_1D() // Check boundaries elm_sp.getSelectBounds(low, high); - verify_val(low[0], (hsize_t)3, "DataSpace::getSelectBounds", __LINE__, __FILE__); - verify_val(high[0], (hsize_t)97, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(static_cast(low[0]), 3, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(static_cast(high[0]), 97, "DataSpace::getSelectBounds", __LINE__, __FILE__); // Close element space elm_sp.close(); diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index 7d0337d..1cedef6 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -110,8 +110,8 @@ test_classes() // PredType::NATIVE_DOUBLE should be in H5T_FLOAT class tcls = PredType::NATIVE_DOUBLE.getClass(); if (H5T_FLOAT != tcls) { - verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, - __FILE__); + verify_val(static_cast(tcls), static_cast(H5T_FLOAT), + "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, __FILE__); } PASSED(); } // end of try block @@ -727,7 +727,7 @@ test_named() Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space); for (hsize_t i = 0; i < ds_size[0]; i++) { for (hsize_t j = 0; j < ds_size[1]; j++) { - attr_data[i][j] = (unsigned)(i * ds_size[1] + j); + attr_data[i][j] = static_cast(i * ds_size[1] + j); } } attr1.write(PredType::NATIVE_UINT, attr_data); @@ -989,7 +989,8 @@ test_encode_decode() // Create an IntType instance from the decoded pointer and verify it IntType * decoded_int_ptr(static_cast(inttyp.decode())); H5T_sign_t int_sign = decoded_int_ptr->getSign(); - verify_val(int_sign, H5T_SGN_NONE, "DataType::decode", __LINE__, __FILE__); + verify_val(static_cast(int_sign), static_cast(H5T_SGN_NONE), "DataType::decode", __LINE__, + __FILE__); verify_val(inttyp == *decoded_int_ptr, true, "DataType::decode", __LINE__, __FILE__); delete decoded_int_ptr; diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index 9c0f78a..c91b566 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -183,7 +183,7 @@ test_vlstring_dataset() // Test scalar type dataset with 1 value. dset1 = root.createDataSet("test_scalar_small", vlst, ds_space); - dynstring_ds_write = (char *)HDcalloc(2, sizeof(char)); + dynstring_ds_write = static_cast(HDcalloc(2, sizeof(char))); HDmemset(dynstring_ds_write, 'A', 1); // Write data to the dataset, then read it back. @@ -285,7 +285,7 @@ test_vlstring_array_dataset() // Create and write another dataset. DataSet dataset2(file1->createDataSet("Dataset2", vlst, scalar_space)); - char * wdata2 = (char *)HDcalloc(65534, sizeof(char)); + char * wdata2 = static_cast(HDcalloc(65534, sizeof(char))); HDmemset(wdata2, 'A', 65533); dataset2.write(&wdata2, vlst); @@ -360,7 +360,7 @@ test_vlstrings_special() hsize_t ii; // counting variable for (ii = 0; ii < SPACE1_DIM1; ii++) if (rdata[ii] != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]); + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", static_cast(ii), rdata[ii]); // Write dataset to disk, then read it back. dataset.write(wdata, vlst); @@ -372,18 +372,19 @@ test_vlstrings_special() size_t rlen = HDstrlen(rdata[ii]); if (wlen != rlen) { TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n", - (int)ii, (unsigned)wlen, (int)ii, (unsigned)rlen); + static_cast(ii), static_cast(wlen), static_cast(ii), + static_cast(rlen)); continue; - } // end if + } if (HDstrcmp(wdata[ii], rdata[ii]) != 0) { - TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)ii, wdata[ii], - (int)ii, rdata[ii]); + TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", + static_cast(ii), wdata[ii], static_cast(ii), rdata[ii]); continue; - } // end if - } // end for + } + } // Reclaim the read VL data. - DataSet::vlenReclaim((void *)rdata, vlst, sid1); + DataSet::vlenReclaim(static_cast(rdata), vlst, sid1); // Close Dataset. dataset.close(); @@ -408,7 +409,7 @@ test_vlstrings_special() // Check data read in. for (ii = 0; ii < SPACE1_DIM1; ii++) if (rdata[ii] != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]); + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", static_cast(ii), rdata[ii]); // Try to write nil strings to disk. dataset.write(wdata2, vlst); @@ -419,7 +420,7 @@ test_vlstrings_special() // Check data read in. for (ii = 0; ii < SPACE1_DIM1; ii++) if (rdata[ii] != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]); + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", static_cast(ii), rdata[ii]); // Close objects and file. dataset.close(); @@ -467,22 +468,26 @@ test_vlstring_type() // Change padding and verify it. vlst.setStrpad(H5T_STR_NULLPAD); H5T_str_t pad = vlst.getStrpad(); - verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); + verify_val(static_cast(pad), static_cast(H5T_STR_NULLPAD), "StrType::getStrpad", __LINE__, + __FILE__); // Convert to variable-length string. vlst.setSize(H5T_VARIABLE); // Check if datatype is VL string. H5T_class_t type_class = vlst.getClass(); - verify_val(type_class, H5T_STRING, "DataType::getClass", __LINE__, __FILE__); + verify_val(static_cast(type_class), static_cast(H5T_STRING), "DataType::getClass", + __LINE__, __FILE__); bool is_variable_str = vlst.isVariableStr(); verify_val(is_variable_str, true, "DataType::isVariableStr", __LINE__, __FILE__); // Check default character set and padding. H5T_cset_t cset = vlst.getCset(); - verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__); + verify_val(static_cast(cset), static_cast(H5T_CSET_ASCII), "StrType::getCset", __LINE__, + __FILE__); pad = vlst.getStrpad(); - verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); + verify_val(static_cast(pad), static_cast(H5T_STR_NULLPAD), "StrType::getStrpad", __LINE__, + __FILE__); // Commit variable-length string datatype to storage. vlst.commit(*file1, VLSTR_TYPE); @@ -510,9 +515,11 @@ test_vlstring_type() // Verify character set and padding cset = vlst2.getCset(); - verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__); + verify_val(static_cast(cset), static_cast(H5T_CSET_ASCII), "StrType::getCset", __LINE__, + __FILE__); pad = vlst2.getStrpad(); - verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); + verify_val(static_cast(pad), static_cast(H5T_STR_NULLPAD), "StrType::getStrpad", __LINE__, + __FILE__); // Close datatype and file vlst2.close(); @@ -578,18 +585,19 @@ test_compact_vlstring() for (i = 0; i < SPACE1_DIM1; i++) { if (HDstrlen(wdata[i]) != strlen(rdata[i])) { TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n", - (int)i, (int)strlen(wdata[i]), (int)i, (int)strlen(rdata[i])); + static_cast(i), static_cast(HDstrlen(wdata[i])), static_cast(i), + static_cast(HDstrlen(rdata[i]))); continue; } // end if if (HDstrcmp(wdata[i], rdata[i]) != 0) { - TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)i, wdata[i], - (int)i, rdata[i]); + TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", + static_cast(i), wdata[i], static_cast(i), rdata[i]); continue; } // end if } // end for // Reclaim the read VL data - DataSet::vlenReclaim((void *)rdata, vlst, sid1); + DataSet::vlenReclaim(static_cast(rdata), vlst, sid1); // Close objects and file dataset.close(); @@ -670,7 +678,7 @@ test_vlstring_attribute() // Test creating a "large" sized string attribute gr_attr = root.createAttribute("test_scalar_large", vlst, att_space); - string_att_write = (char *)HDcalloc(8192, sizeof(char)); + string_att_write = static_cast(HDcalloc(8192, sizeof(char))); HDmemset(string_att_write, 'A', 8191); // Write data to the attribute, then read it back. diff --git a/config/cmake/H5cxx_config.h.in b/config/cmake/H5cxx_config.h.in deleted file mode 100644 index b5ae8ce..0000000 --- a/config/cmake/H5cxx_config.h.in +++ /dev/null @@ -1,16 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* src/H5cxx_config.h.in Created manually. */ - -/* Define if offsetof extension is present */ -#cmakedefine H5_HAVE_OFFSETOF ${H5_HAVE_OFFSETOF} - diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index dd7fa21..8f32e58 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -26,9 +26,6 @@ /* Define if using a Windows compiler (i.e. Visual Studio) */ #cmakedefine H5_HAVE_VISUAL_STUDIO @H5_HAVE_VISUAL_STUDIO@ -/* Define if C++ compiler recognizes offsetof */ -#cmakedefine H5_CXX_HAVE_OFFSETOF @CXX_HAVE_OFFSETOF@ - /* Define the default plugins path to compile */ #cmakedefine H5_DEFAULT_PLUGINDIR "@H5_DEFAULT_PLUGINDIR@" @@ -201,9 +198,6 @@ /* Define to 1 if you have the `ioctl' function. */ #cmakedefine H5_HAVE_IOCTL @H5_HAVE_IOCTL@ -/* Define to 1 if you have the header file. */ -#cmakedefine H5_HAVE_IO_H @H5_HAVE_IO_H@ - /* Define to 1 if you have the `crypto' library (-lcrypto). */ #cmakedefine H5_HAVE_LIBCRYPTO @H5_HAVE_LIBCRYPTO@ diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index 003f24f..67f47ec 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -129,74 +129,12 @@ endif () # Determine the available KINDs for REALs and INTEGERs #----------------------------------------------------------------------------- -#READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE) -set (PROG_SRC_CODE - " - PROGRAM FC_AVAIL_KINDS - IMPLICIT NONE - INTEGER :: ik, jk, k, max_decimal_prec - INTEGER :: num_rkinds = 1, num_ikinds = 1 - INTEGER, DIMENSION(1:10) :: list_ikinds = -1 - INTEGER, DIMENSION(1:10) :: list_rkinds = -1 - - OPEN(8, FILE='pac_fconftest.out', FORM='formatted') - - ! Find integer KINDs - list_ikinds(num_ikinds)=SELECTED_INT_KIND(1) - DO ik = 2, 36 - k = SELECTED_INT_KIND(ik) - IF(k.LT.0) EXIT - IF(k.GT.list_ikinds(num_ikinds))THEN - num_ikinds = num_ikinds + 1 - list_ikinds(num_ikinds) = k - ENDIF - ENDDO - - DO k = 1, num_ikinds - WRITE(8,'(I0)', ADVANCE='NO') list_ikinds(k) - IF(k.NE.num_ikinds)THEN - WRITE(8,'(A)',ADVANCE='NO') ',' - ELSE - WRITE(8,'()') - ENDIF - ENDDO - - ! Find real KINDs - list_rkinds(num_rkinds)=SELECTED_REAL_KIND(1) - max_decimal_prec = 1 - - prec: DO ik = 2, 36 - exp: DO jk = 1, 17000 - k = SELECTED_REAL_KIND(ik,jk) - IF(k.LT.0) EXIT exp - IF(k.GT.list_rkinds(num_rkinds))THEN - num_rkinds = num_rkinds + 1 - list_rkinds(num_rkinds) = k - ENDIF - max_decimal_prec = ik - ENDDO exp - ENDDO prec - - DO k = 1, num_rkinds - WRITE(8,'(I0)', ADVANCE='NO') list_rkinds(k) - IF(k.NE.num_rkinds)THEN - WRITE(8,'(A)',ADVANCE='NO') ',' - ELSE - WRITE(8,'()') - ENDIF - ENDDO - - WRITE(8,'(I0)') max_decimal_prec - WRITE(8,'(I0)') num_ikinds - WRITE(8,'(I0)') num_rkinds - END PROGRAM FC_AVAIL_KINDS - " -) +READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE) if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - check_fortran_source_runs (${PROG_SRC_CODE} FC_AVAIL_KINDS_RESULT SRC_EXT f90) + check_fortran_source_runs (${SOURCE_CODE} FC_AVAIL_KINDS_RESULT SRC_EXT f90) else () FORTRAN_RUN ("REAL and INTEGER KINDs" - "${PROG_SRC_CODE}" + "${SOURCE_CODE}" XX YY FC_AVAIL_KINDS_RESULT @@ -260,7 +198,7 @@ foreach (KIND ${VAR}) USE ISO_C_BINDING IMPLICIT NONE INTEGER (KIND=${KIND}) a - OPEN(8,FILE='pac_validIntKinds.out',FORM='formatted') + OPEN(8,FILE='pac_validIntKinds.${KIND}.out',FORM='formatted') WRITE(8,'(I0)') ${FC_SIZEOF_A} CLOSE(8) END @@ -271,7 +209,7 @@ foreach (KIND ${VAR}) else () FORTRAN_RUN("INTEGER KIND SIZEOF" ${PROG_SRC_${KIND}} XX YY VALIDINTKINDS_RESULT_${KIND}) endif () - file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validIntKinds.out" PROG_OUTPUT1) + file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validIntKinds.${KIND}.out" PROG_OUTPUT1) string (REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") set (pack_int_sizeof "${pack_int_sizeof} ${PROG_OUTPUT1},") endforeach () @@ -309,7 +247,7 @@ foreach (KIND ${VAR} ) USE ISO_C_BINDING IMPLICIT NONE REAL (KIND=${KIND}) a - OPEN(8,FILE='pac_validRealKinds.out',FORM='formatted') + OPEN(8,FILE='pac_validRealKinds.${KIND}.out',FORM='formatted') WRITE(8,'(I0)') ${FC_SIZEOF_A} CLOSE(8) END @@ -320,7 +258,7 @@ foreach (KIND ${VAR} ) else () FORTRAN_RUN ("REAL KIND SIZEOF" ${PROG_SRC2_${KIND}} XX YY VALIDREALKINDS_RESULT_${KIND}) endif () - file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validRealKinds.out" PROG_OUTPUT1) + file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validRealKinds.${KIND}.out" PROG_OUTPUT1) string (REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") set (pack_real_sizeof "${pack_real_sizeof} ${PROG_OUTPUT1},") endforeach () diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index e2904ca..260bbe0 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -71,10 +71,6 @@ endif () # HDF5 library compile options #----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- if (NOT MSVC AND NOT MINGW) if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") list (APPEND HDF5_CMAKE_CXX_FLAGS "-erroff=%none -DBSD_COMP") @@ -121,9 +117,9 @@ if (NOT MSVC AND NOT MINGW) #----------------------------------------------------------------------------- if (HDF5_ENABLE_DEV_WARNINGS) message (STATUS "....HDF5 developer group warnings are enabled") - # if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - # list (APPEND H5_CXXFLAGS "-Winline -Wreorder -Wport -Wstrict-aliasing") - # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + # list (APPEND H5_CXXFLAGS "-Winline -Wreorder -Wport -Wstrict-aliasing") + # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") @@ -147,7 +143,7 @@ if (NOT MSVC AND NOT MINGW) ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8-4.last") endif () - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") if (HDF5_ENABLE_DEV_WARNINGS) @@ -157,14 +153,14 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-4.9") endif () - # Append more extra warning flags that only gcc 5.1+ know about + # Append more extra warning flags that only gcc 5.1+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-5") @@ -175,13 +171,13 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXxFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") @@ -193,7 +189,7 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") @@ -211,10 +207,11 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-9") endif () endif () else () diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index bb6ad78..0775f59 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -81,10 +81,6 @@ endif () # HDF5 library compile options #----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- if (NOT MSVC AND NOT MINGW) #----------------------------------------------------------------------------- # Option to allow the user to interpret certain warnings as errors @@ -178,7 +174,7 @@ if (NOT MSVC AND NOT MINGW) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8-4.last") endif () - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") if (HDF5_ENABLE_DEV_WARNINGS) @@ -188,12 +184,12 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") endif () - # Append more extra warning flags that only gcc 5.x+ know about + # Append more extra warning flags that only gcc 5.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/5") if (HDF5_ENABLE_WARNINGS_AS_ERRORS) @@ -203,12 +199,12 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") if (HDF5_ENABLE_DEV_WARNINGS) @@ -218,7 +214,7 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") if (HDF5_ENABLE_WARNINGS_AS_ERRORS) @@ -231,17 +227,17 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") endif () - # Append more extra warning flags that only gcc 9.3+ know about + # Append more extra warning flags that only gcc 9.3+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.3) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9.3") endif () - # Append more extra warning flags that only gcc 10.x+ know about + # Append more extra warning flags that only gcc 10.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0) if (HDF5_ENABLE_DEV_WARNINGS) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-10") diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 8b631ad..18ab621 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -80,37 +80,37 @@ if (NOT MSVC AND NOT MINGW) if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.9) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") #endif () - # Append more extra warning flags that only gcc 5.x+ know about + # Append more extra warning flags that only gcc 5.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") #endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") #endif () diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 366cf16..0a27692 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -123,19 +123,10 @@ CHECK_INCLUDE_FILE_CONCAT ("stddef.h" ${HDF_PREFIX}_HAVE_STDDEF_H) CHECK_INCLUDE_FILE_CONCAT ("unistd.h" ${HDF_PREFIX}_HAVE_UNISTD_H) # Windows -CHECK_INCLUDE_FILE_CONCAT ("io.h" ${HDF_PREFIX}_HAVE_IO_H) if (NOT CYGWIN) CHECK_INCLUDE_FILE_CONCAT ("winsock2.h" ${HDF_PREFIX}_HAVE_WINSOCK2_H) endif () -if (CMAKE_SYSTEM_NAME MATCHES "OSF") - CHECK_INCLUDE_FILE_CONCAT ("sys/sysinfo.h" ${HDF_PREFIX}_HAVE_SYS_SYSINFO_H) - CHECK_INCLUDE_FILE_CONCAT ("sys/proc.h" ${HDF_PREFIX}_HAVE_SYS_PROC_H) -else () - set (${HDF_PREFIX}_HAVE_SYS_SYSINFO_H "" CACHE INTERNAL "" FORCE) - set (${HDF_PREFIX}_HAVE_SYS_PROC_H "" CACHE INTERNAL "" FORCE) -endif () - CHECK_INCLUDE_FILE_CONCAT ("globus/common.h" ${HDF_PREFIX}_HAVE_GLOBUS_COMMON_H) CHECK_INCLUDE_FILE_CONCAT ("pdb.h" ${HDF_PREFIX}_HAVE_PDB_H) CHECK_INCLUDE_FILE_CONCAT ("pthread.h" ${HDF_PREFIX}_HAVE_PTHREAD_H) diff --git a/config/cmake_ext_mod/HDFCXXTests.cpp b/config/cmake_ext_mod/HDFCXXTests.cpp deleted file mode 100644 index 08ccb34..0000000 --- a/config/cmake_ext_mod/HDFCXXTests.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifdef CXX_HAVE_OFFSETOF - -#include -#include - -#ifdef FC_DUMMY_MAIN -#ifndef FC_DUMMY_MAIN_EQ_F77 -# ifdef __cplusplus -extern "C" -# endif -int FC_DUMMY_MAIN() -{ return 1;} -#endif -#endif -int -main () -{ - - struct index_st - { - unsigned char type; - unsigned char num; - unsigned int len; - }; - typedef struct index_st index_t; - int x,y; - x = offsetof(struct index_st, len); - y = offsetof(index_t, num) - - ; - return 0; -} - -#endif diff --git a/config/cmake_ext_mod/HDFUseCXX.cmake b/config/cmake_ext_mod/HDFUseCXX.cmake deleted file mode 100644 index 423f74a..0000000 --- a/config/cmake_ext_mod/HDFUseCXX.cmake +++ /dev/null @@ -1,99 +0,0 @@ -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# -# This file provides functions for C++ support. -# -#------------------------------------------------------------------------------- -ENABLE_LANGUAGE (CXX) -set (HDF_PREFIX "H5") - -#------------------------------------------------------------------------------- -# Fix CXX flags if we are compiling staticly on Windows using -# Windows_MT.cmake from config/cmake/UserMacros -#------------------------------------------------------------------------------- -if (BUILD_STATIC_CRT_LIBS) - TARGET_STATIC_CRT_FLAGS () -endif () - -#----------------------------------------------------------------------------- -# Configure Checks which require CXX compilation must go in here -# not in the main ConfigureChecks.cmake files, because if the user has -# no CXX compiler, problems arise. -#----------------------------------------------------------------------------- -include (CheckIncludeFileCXX) -include (TestForSTDNamespace) - -# For other CXX specific tests, use this MACRO. -macro (HDF_CXX_FUNCTION_TEST OTHER_TEST) - if (NOT DEFINED ${OTHER_TEST}) - set (MACRO_CHECK_FUNCTION_DEFINITIONS "-D${OTHER_TEST} ${CMAKE_REQUIRED_FLAGS}") - set (OTHER_TEST_ADD_LIBRARIES) - if (HDF5_REQUIRED_LIBRARIES) - set (OTHER_TEST_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${HDF5_REQUIRED_LIBRARIES}") - endif () - - foreach (def - HAVE_SYS_TIME_H - HAVE_UNISTD_H - HAVE_SYS_TYPES_H - HAVE_SYS_SOCKET_H - HAVE_SYS_FILE_H - ) - if ("${${HDF_PREFIX}_${def}}") - set (MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D${def}") - endif () - endforeach () - - if (LARGEFILE) - set (MACRO_CHECK_FUNCTION_DEFINITIONS - "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE" - ) - endif () - - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (TRACE "Performing ${OTHER_TEST}") - endif () - TRY_COMPILE (${OTHER_TEST} - ${CMAKE_BINARY_DIR} - ${HDF_RESOURCES_EXT_DIR}/HDFCXXTests.cpp - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} - "${OTHER_TEST_ADD_LIBRARIES}" - OUTPUT_VARIABLE OUTPUT - ) - if (${OTHER_TEST} EQUAL 0) - set (${OTHER_TEST} 1 CACHE INTERNAL "CXX test ${FUNCTION}") - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Performing CXX Test ${OTHER_TEST} - Success") - endif () - else () - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Performing CXX Test ${OTHER_TEST} - Failed") - endif () - set (${OTHER_TEST} "" CACHE INTERNAL "CXX test ${FUNCTION}") - file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log - "Performing CXX Test ${OTHER_TEST} failed with the following output:\n" - "${OUTPUT}\n" - ) - endif () - endif () -endmacro () - -#----------------------------------------------------------------------------- -# Check a bunch of cxx functions -#----------------------------------------------------------------------------- -if (CMAKE_CXX_COMPILER_LOADED) - foreach (cxx_test - CXX_HAVE_OFFSETOF - ) - HDF_CXX_FUNCTION_TEST (${cxx_test}) - endforeach () -endif () diff --git a/config/gnu-cxxflags b/config/gnu-cxxflags index 0a7c63e..4fe5782 100644 --- a/config/gnu-cxxflags +++ b/config/gnu-cxxflags @@ -260,6 +260,7 @@ if test "X-g++" = "X-$cxx_vendor"; then # gcc 9 if test $cxx_vers_major -ge 9; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 9)" + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-9)" fi ################# diff --git a/config/gnu-warnings/cxx-9 b/config/gnu-warnings/cxx-9 new file mode 100644 index 0000000..d897de2 --- /dev/null +++ b/config/gnu-warnings/cxx-9 @@ -0,0 +1,2 @@ +# Turn this on when the C++ wrappers obey the Rule of Five +-Wno-deprecated-copy diff --git a/config/intel-cxxflags b/config/intel-cxxflags new file mode 100644 index 0000000..3ef172f --- /dev/null +++ b/config/intel-cxxflags @@ -0,0 +1,128 @@ +# -*- shell-script -*- +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. + + +# This file should be sourced into configure if the compiler is the +# Intel icpc compiler or a derivative. It is careful not to do anything +# if the compiler is not Intel; otherwise `cxx_flags_set' is set to `yes' +# + +# Get the compiler version in a way that works for icpc +# icpc unless a compiler version is already known +# +# cxx_vendor: The compiler name: icpc +# cxx_version: Version number: 8.0 +# +if test X = "X$cxx_flags_set"; then + cxx_version="`$CXX $CXXFLAGS $H5_CXXFLAGS -V 2>&1 |grep 'Version'`" + if test X != "X$cxx_version"; then + cxx_vendor=icpc + cxx_version=`echo $cxx_version |sed 's/.*Version \([-a-z0-9\.\-]*\).*/\1/'` + echo "compiler '$CXX' is Intel $cxx_vendor-$cxx_version" + + # Some version numbers + # Intel version numbers are of the form: "major.minor" + cxx_vers_major=`echo $cxx_version | cut -f1 -d.` + cxx_vers_minor=`echo $cxx_version | cut -f2 -d.` + #cxx_vers_patch=`echo $cxx_version | cut -f2 -d.` + test -n "$cxx_vers_major" || cxx_vers_major=0 + test -n "$cxx_vers_minor" || cxx_vers_minor=0 + test -n "$cxx_vers_patch" || cxx_vers_patch=0 + cxx_vers_all=`expr $cxx_vers_major '*' 1000000 + $cxx_vers_minor '*' 1000 + $cxx_vers_patch` + fi +fi + +# Common Intel flags for various situations +if test "X-icpc" = "X-$cxx_vendor"; then + # Insert section about version specific problems from compiler flags here, + # if necessary. + + arch= + # Architecture-specific flags + # Nothing currently. (Uncomment code below and modify to add any) + #case "$host_os-$host_cpu" in + # *-i686) + # arch="-march=i686" + # ;; + #esac + + # Host-specific flags + # Nothing currently. (Uncomment code below and modify to add any) + #case "`hostname`" in + # sleipnir.ncsa.uiuc.edu) + # arch="$arch -pipe" + # ;; + #esac + + ########### + # General # + ########### + + # Default to C++11 standard + H5_CXXFLAGS="$H5_CXXFLAGS $arch -std=c++11" + + ############## + # Production # + ############## + + PROD_CXXFLAGS= + + ######### + # Debug # + ######### + + # NDEBUG is handled explicitly by the configure script + # -g is handled by the symbols flags + DEBUG_CXXFLAGS= + + ########### + # Symbols # + ########### + + SYMBOLS_CXXFLAGS="-g" + NO_SYMBOLS_CXXFLAGS="-Wl,-s" + + ############# + # Profiling # + ############# + + # Use this for profiling with gprof + PROFILE_CXXFLAGS="-p" + + ################ + # Optimization # + ################ + + HIGH_OPT_CXXFLAGS="-O3" + DEBUG_OPT_CXXFLAGS="-O0" + NO_OPT_CXXFLAGS="-O0" + + ############ + # Warnings # + ############ + + ############################# + # Version-specific warnings # + ############################# + + ################# + # Flags are set # + ################# + cxx_flags_set=yes + +fi + +# Clear cc info if no flags set +if test "X-$cxx_flags_set" = "X-"; then + cxx_vendor= + cxx_version= +fi diff --git a/config/linux-gnulibc1 b/config/linux-gnulibc1 index 0fef161..d952c4e 100644 --- a/config/linux-gnulibc1 +++ b/config/linux-gnulibc1 @@ -199,9 +199,16 @@ if test -z "$CXX"; then CXX_BASENAME=g++ fi +# Figure out Intel CXX compiler flags +# Do this ahead of GNU to avoid icpc being detected as g++ +. $srcdir/config/intel-cxxflags + # Figure out GNU CXX compiler flags . $srcdir/config/gnu-cxxflags +# Figure out PGI CXX compiler flags +. $srcdir/config/pgi-cxxflags + # Figure out Clang CXX compiler flags . $srcdir/config/clang-cxxflags @@ -314,6 +321,9 @@ fi # check if the compiler_version_info is already set if test -z "$cxx_version_info"; then case $CXX in + *pgc++*) + cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS -V 2>&1 | grep 'pgc++'` + ;; *g++*) cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS --version 2>&1 |\ grep 'GCC' | sed 's/\(.*(GCC) [-a-z0-9\. ]*\).*/\1/'` @@ -322,10 +332,6 @@ case $CXX in cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS -V 2>&1 | grep 'Version' |\ sed 's/\(Intel.* Compiler\).*\( Version [a-z0-9\.]*\).*\( Build [0-9]*\)/\1\2\3/'` ;; - *pgCC*) - cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS -V 2>&1 | grep 'pgCC'` - ;; - *mpicxx*) cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS -v 2>&1 | grep 'version' |\ sed 's/^[a-z0-9]* for //' |\ diff --git a/config/pgi-cxxflags b/config/pgi-cxxflags new file mode 100644 index 0000000..3b87db2 --- /dev/null +++ b/config/pgi-cxxflags @@ -0,0 +1,96 @@ +# -*- shell-script -*- +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. + + +# This file should be sourced into configure if the compiler is the +# PGI pgc++ compiler or a derivative. It is careful not to do anything +# if the compiler is not PGI; otherwise `cxx_flags_set' is set to `yes' +# + +# Get the compiler version in a way that works for pgc++ +# pgc++ unless a compiler version is already known +# +# cxx_vendor: The compiler name: pgc++ +# cxx_version: Version number: 5.0-2, 5.2-2 +# +if test X = "X$cxx_flags_set"; then + cxx_version="`$CXX $CXXFLAGS -V 2>&1 |grep '^pgc++ '`" + if test X != "X$cxx_version"; then + cxx_vendor=`echo $cxx_version |sed 's/\([a-z]*++\).*/\1/'` + cxx_version=`echo $cxx_version |sed 's/pgc++ \([-a-z0-9\.\-]*\).*/\1/'` + echo "compiler '$CXX' is PGI $cxx_vendor-$cxx_version" + + # Some version numbers + # PGI version numbers are of the form: "major.minor-patch" + cxx_vers_major=`echo $cxx_version | cut -f1 -d.` + cxx_vers_minor=`echo $cxx_version | cut -f2 -d. | cut -f1 -d-` + cxx_vers_patch=`echo $cxx_version | cut -f2 -d. | cut -f2 -d-` + test -n "$cxx_vers_major" || cxx_vers_major=0 + test -n "$cxx_vers_minor" || cxx_vers_minor=0 + test -n "$cxx_vers_patch" || cxx_vers_patch=0 + cxx_vers_all=`expr $cxx_vers_major '*' 1000000 + $cxx_vers_minor '*' 1000 + $cxx_vers_patch` + fi +fi + +# Common PGI flags for various situations +if test "X-pgc++" = "X-$cxx_vendor"; then + + # C++-specific + H5_CXXFLAGS="$H5_CXXFLAGS -std=c++11 -Minform=warn" + + ############## + # Production # + ############## + + # NDEBUG is handled explicitly by the configure script + PROD_CXXFLAGS="-fast" + + ######### + # Debug # + ######### + + # NDEBUG is handled explicitly by the configure script + # -g is handled by the symbols flags + DEBUG_CXXFLAGS="-Mbounds" + + ########### + # Symbols # + ########### + + SYMBOLS_CXXFLAGS="-g" + NO_SYMBOLS_CXXFLAGS="-s" + + ############# + # Profiling # + ############# + + PROFILE_CXXFLAGS="-Mprof=func,line" + # Use this for profiling with gprof + #PROFILE_CXXFLAGS="-pg" + + ################ + # Optimization # + ################ + + HIGH_OPT_CXXFLAGS="-O4" + DEBUG_OPT_CXXFLAGS="-gopt -O2" + NO_OPT_CXXFLAGS="-O0" + + # Flags are set + cxx_flags_set=yes +fi + +# Clear cxx info if no flags set +if test "X-$cxx_flags_set" = "X-"; then + cxx_vendor= + cxx_version= +fi diff --git a/config/pgi-flags b/config/pgi-flags index e1bec00..24c7174 100644 --- a/config/pgi-flags +++ b/config/pgi-flags @@ -66,50 +66,45 @@ if test "X-pgcc" = "X-$cc_vendor"; then #esac # General - H5_CFLAGS="$H5_CFLAGS $arch -c99 -Minform=inform" - - # Production - case "$cc_vendor-$cc_version" in - pgcc-10.6*) - PROD_CFLAGS= - ;; - pgcc-9.*) - PROD_CFLAGS= - ;; - *) - PROD_CFLAGS="-fast" - ;; - esac - - # Debug + H5_CFLAGS="$H5_CFLAGS $arch -c99 -Minform=warn" + + ############## + # Production # + ############## + + # NDEBUG is handled explicitly by the configure script + PROD_CFLAGS="-fast" + + ######### + # Debug # + ######### + # NDEBUG is handled explicitly by the configure script + # -g is handled by the symbols flags DEBUG_CFLAGS="-Mbounds" - # Symbols + ########### + # Symbols # + ########### + SYMBOLS_CFLAGS="-g" NO_SYMBOLS_CFLAGS="-s" - # Profiling + ############# + # Profiling # + ############# + PROFILE_CFLAGS="-Mprof=func,line" # Use this for profiling with gprof #PROFILE_CFLAGS="-pg" - # Optimization - case "$cc_vendor-$cc_version" in - # Tweak down compiler optimizations for v10.6, it has a bug - pgcc-10.6*) - HIGH_OPT_CFLAGS="-O1" - ;; - # Tweak down compiler optimizations for v9.x - pgcc-9.*) - HIGH_OPT_CFLAGS="-O1" - ;; - *) - HIGH_OPT_CFLAGS= - ;; - esac - DEBUG_OPT_CFLAGS= - NO_OPT_CFLAGS= + ################ + # Optimization # + ################ + + HIGH_OPT_CFLAGS="-O4" + DEBUG_OPT_CFLAGS="-gopt -O2" + NO_OPT_CFLAGS="-O0" # Flags are set cc_flags_set=yes diff --git a/configure.ac b/configure.ac index 50d0cea..1a5ddf7 100644 --- a/configure.ac +++ b/configure.ac @@ -776,20 +776,6 @@ if test "X$HDF_CXX" = "Xyes"; then ## Change to the C++ language AC_LANG_PUSH(C++) - ## Checking if C++ needs old style header files in includes - PAC_PROG_CXX_HEADERS - - ## Checking if C++ can handle namespaces - PAC_PROG_CXX_NAMESPACE - - ## if C++ can handle static cast - PAC_PROG_CXX_STATIC_CAST - - ## Checking if C++ has offsetof extension, - ## note: this test has to be the last of the C++ tests because it sets a definition - ## which would be used in the other tests, causing them to fail. - PAC_PROG_CXX_OFFSETOF - else AC_MSG_RESULT([no]) CXX="no" @@ -1266,15 +1252,15 @@ esac ## Windows case "`uname`" in CYGWIN*) - AC_CHECK_HEADERS([io.h sys/timeb.h]) + AC_CHECK_HEADERS([sys/timeb.h]) UNAME_CYGWIN="yes" ;; MINGW*) - AC_CHECK_HEADERS([io.h winsock2.h sys/timeb.h]) + AC_CHECK_HEADERS([winsock2.h sys/timeb.h]) AC_HAVE_LIBRARY([ws2_32]) ;; *) - AC_CHECK_HEADERS([io.h winsock2.h sys/timeb.h]) + AC_CHECK_HEADERS([winsock2.h sys/timeb.h]) ;; esac diff --git a/hl/c++/src/H5PacketTable.cpp b/hl/c++/src/H5PacketTable.cpp index 0f47b0d..3fcc9b2 100644 --- a/hl/c++/src/H5PacketTable.cpp +++ b/hl/c++/src/H5PacketTable.cpp @@ -32,15 +32,13 @@ * Opens an existing packet table, which can contain either fixed-length or * variable-length packets. */ -PacketTable::PacketTable(hid_t fileID, const char *name) +PacketTable::PacketTable(hid_t fileID, const char *name) : table_id{H5PTopen(fileID, name)} { - table_id = H5PTopen(fileID, name); } /* "Open" Constructor - will be deprecated because of char* name */ -PacketTable::PacketTable(hid_t fileID, char *name) +PacketTable::PacketTable(hid_t fileID, char *name) : table_id{H5PTopen(fileID, name)} { - table_id = H5PTopen(fileID, name); } /* Destructor @@ -271,7 +269,7 @@ FL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, void *data) if (startIndex > endIndex) return -1; - return H5PTread_packets(table_id, startIndex, (size_t)(endIndex - startIndex + 1), data); + return H5PTread_packets(table_id, startIndex, static_cast(endIndex - startIndex + 1), data); } /* GetNextPacket (single packet) diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h index acd0ccf..306cc2f 100644 --- a/hl/c++/src/H5PacketTable.h +++ b/hl/c++/src/H5PacketTable.h @@ -33,9 +33,8 @@ class H5_HLCPPDLL PacketTable { /* Null constructor * Sets table_id to "invalid" */ - PacketTable() + PacketTable() : table_id{H5I_INVALID_HID} { - table_id = H5I_INVALID_HID; } /* "Open" Constructor diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp index 2600367..6deb24d 100644 --- a/hl/c++/test/ptableTest.cpp +++ b/hl/c++/test/ptableTest.cpp @@ -307,7 +307,7 @@ TestCompress() if (HDstrncmp(filter_name, "deflate", 7) != 0) H5_FAILED() } - catch (Exception e) { + catch (Exception const &) { H5_FAILED(); return 1; } @@ -605,8 +605,8 @@ const int STRING_LENGTH = 19; // including terminating NULL int TestHDFFV_9758() { - hid_t strtype; - hid_t compound_type; + hid_t strtype = H5I_INVALID_HID; + hid_t compound_type = H5I_INVALID_HID; herr_t err; struct s1_t { int a; @@ -620,9 +620,9 @@ TestHDFFV_9758() for (hsize_t i = 0; i < NUM_PACKETS; i++) { s1[i].a = static_cast(i); - s1[i].b = 1.f * static_cast(i * i); - s1[i].c = 1. / (i + 1); - HDsprintf(s1[i].d, "string%d", (int)i); + s1[i].b = 1.0f * static_cast(i * i); + s1[i].c = 1.0 / static_cast(i + 1); + HDsprintf(s1[i].d, "string%" PRIuHSIZE "", i); s1[i].e = static_cast(100 + i); } diff --git a/m4/aclocal_cxx.m4 b/m4/aclocal_cxx.m4 deleted file mode 100644 index 2779066..0000000 --- a/m4/aclocal_cxx.m4 +++ /dev/null @@ -1,79 +0,0 @@ -dnl ------------------------------------------------------------------------- -dnl ------------------------------------------------------------------------- -dnl -dnl Copyright by the Board of Trustees of the University of Illinois. -dnl All rights reserved. -dnl -dnl This file is part of HDF5. The full HDF5 copyright notice, including -dnl terms governing use, modification, and redistribution, is contained in -dnl the COPYING file, which can be found at the root of the source code -dnl distribution tree, or in https://www.hdfgroup.org/licenses. -dnl If you do not have access to either file, you may request a copy from -dnl help@hdfgroup.org -dnl -dnl ------------------------------------------------------------------------- -dnl ------------------------------------------------------------------------- - -dnl ********************************* -dnl PURPOSE -dnl Contains Macros for HDF5 C++ -dnl ********************************* -dnl -dnl Special characteristics that have no autoconf counterpart but that -dnl we need as part of the C++ support. To distinquish these, they -dnl have a [PAC] prefix. - -dnl Checking if C++ needs old style header files in includes -AC_DEFUN([PAC_PROG_CXX_HEADERS],[ - AC_MSG_CHECKING([if $CXX needs old style header files in includes]) - TEST_SRC="`(echo \"#define OLD_HEADER_FILENAME 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" - - AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], - [AC_MSG_RESULT([no])], - [AC_MSG_RESULT([yes]) - CXXFLAGS="${CXXFLAGS} -DOLD_HEADER_FILENAME" - AM_CXXFLAGS="${AM_CXXFLAGS} -DOLD_HEADER_FILENAME"]) -]) - -dnl Checking if ++ can handle namespaces -AC_DEFUN([PAC_PROG_CXX_NAMESPACE],[ - AC_MSG_CHECKING([if $CXX can handle namespaces]) - TEST_SRC="`(echo \"#define HDF_NO_NAMESPACE 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" - - AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - CXXFLAGS="${CXXFLAGS} -DHDF_NO_NAMESPACE" - AM_CXXFLAGS="${AM_CXXFLAGS} -DHDF_NO_NAMESPACE"]) -]) - -dnl Checking if C++ supports std -AC_DEFUN([PAC_PROG_CXX_STD],[ - AC_MSG_CHECKING([if $CXX supports std]) - TEST_SRC="`(echo \"#define HDF_NO_STD 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" - - AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - CXXFLAGS="${CXXFLAGS} -DH5_NO_STD" - AM_CXXFLAGS="${AM_CXXFLAGS} -DH5_NO_STD"]) -]) - -dnl Checking if C++ has offsetof extension -AC_DEFUN([PAC_PROG_CXX_OFFSETOF],[ - AC_MSG_CHECKING([if $CXX has offsetof extension]) - TEST_SRC="`(echo \"#define CXX_HAVE_OFFSETOF 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" - - AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])],[AC_MSG_RESULT([yes]) - AC_DEFINE([CXX_HAVE_OFFSETOF], [1], [Define if C++ compiler recognizes offsetof])], - AC_MSG_RESULT([no])) -]) - -dnl Checking if C++ can handle static cast -AC_DEFUN([PAC_PROG_CXX_STATIC_CAST],[ - AC_MSG_CHECKING([if $CXX can handle static cast]) - TEST_SRC="`(echo \"#define NO_STATIC_CAST 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" - - AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - CXXFLAGS="${CXXFLAGS} -DNO_STATIC_CAST" - AM_CXXFLAGS="${AM_CXXFLAGS} -DNO_STATIC_CAST"]) -]) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 20d561c..2d55ae1 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -49,6 +49,32 @@ New Features Configuration: ------------- + - Adds C++ Autotools configuration file for Intel + + * Checks for icpc as the compiler + * Sets std=c++11 + * Copies most non-warning flags from intel-flags + + (DER - 2021/06/02) + + - Adds C++ Autotools configuration file for PGI + + * Checks for pgc++ as the compiler name (was: pgCC) + * Sets -std=c++11 + * Other options basically match new C options (below) + + (DER - 2021/06/02) + + - Updates PGI C options + + * -Minform set to warn (was: inform) to suppress spurious messages + * Sets -gopt -O2 as debug options + * Sets -O4 as 'high optimization' option + * Sets -O0 as 'no optimization' option + * Removes specific settings for PGI 9 and 10 + + (DER - 2021/06/02) + - A C++11-compliant compiler is now required to build the C++ wrappers CMAKE_CXX_STANDARD is now set to 11 when building with CMake and @@ -56,7 +82,6 @@ New Features (DER - 2021/05/27) - - CMake will now run the shell script tests in test/ by default The test directory includes several shell script tests that previously diff --git a/src/H5O.c b/src/H5O.c index 4876bb0..9ddd789 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1183,14 +1183,13 @@ H5Oget_info_by_name_async(const char *app_file, const char *app_func, unsigned a hid_t es_id) { H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ - void * token = NULL; /* Request token for async operation */ - void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + void * token = NULL; /* Request token for async operation */ + void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - /* clang-format off */ - H5TRACE9("e", "*s*sIui*sxIuii", app_file, app_func, app_line, loc_id, name, oinfo, fields, lapl_id, es_id); - /* clang-format on */ + H5TRACE9("e", "*s*sIui*sxIuii", app_file, app_func, app_line, loc_id, name, oinfo, fields, lapl_id, + es_id); /* Set up request token pointer for asynchronous operation */ if (H5ES_NONE != es_id) diff --git a/src/H5detect.c b/src/H5detect.c index 84b34e6..d148301 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -1655,21 +1655,6 @@ main(int argc, char *argv[]) if (!rawoutstream) rawoutstream = stdout; -#if defined(H5_HAVE_SETSYSINFO) && defined(SSI_NVPAIRS) -#if defined(UAC_NOPRINT) && defined(UAC_SIGBUS) - /* - * Make sure unaligned access generates SIGBUS and doesn't print warning - * messages so that we can detect alignment constraints on the DEC Alpha. - */ - int nvpairs[2]; - nvpairs[0] = SSIN_UACPROC; - nvpairs[1] = UAC_NOPRINT | UAC_SIGBUS; - if (setsysinfo(SSI_NVPAIRS, nvpairs, 1, 0, 0) < 0) { - fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n", HDstrerror(errno)); - } -#endif -#endif - #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) /* verify the SIGBUS and SIGSEGV handlers work properly */ if (verify_signal_handlers(SIGBUS, sigbus_handler) != 0) { diff --git a/src/H5private.h b/src/H5private.h index ae8f886..07272eb 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -127,21 +127,6 @@ #endif /* - * System information. These are needed on the DEC Alpha to turn off fixing - * of unaligned accesses by the operating system during detection of - * alignment constraints in H5detect.c:main(). - */ -#ifdef H5_HAVE_SYS_SYSINFO_H -#include -#endif -#ifdef H5_HAVE_SYS_PROC_H -#include -#endif -#ifdef H5_HAVE_IO_H -#include -#endif - -/* * Dynamic library handling. These are needed for dynamically loading I/O * filters and VFDs. */ @@ -182,6 +167,7 @@ #include #include /* For _getcwd() */ +#include /* POSIX I/O */ #endif /*H5_HAVE_WIN32_API*/ diff --git a/src/H5public.h b/src/H5public.h index 33f8b37..b548889 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -217,7 +217,14 @@ typedef int herr_t; typedef bool hbool_t; typedef int htri_t; -/* Define the ssize_t type if it not is defined */ +/* The signed version of size_t + * + * ssize_t is POSIX and not defined in any C standard. It's used in some + * public HDF5 API calls so this work-around will define it if it's not + * present. + * + * Use of ssize_t should be discouraged in new code. + */ #if H5_SIZEOF_SSIZE_T == 0 /* Undefine this size, we will re-define it in one of the sections below */ #undef H5_SIZEOF_SSIZE_T @@ -235,137 +242,47 @@ typedef long long ssize_t; #endif #endif -/* int64_t type is used for creation order field for links. It may be - * defined in Posix.1g, otherwise it is defined here. - */ -#if H5_SIZEOF_INT64_T >= 8 -#elif H5_SIZEOF_INT >= 8 -typedef int int64_t; -#undef H5_SIZEOF_INT64_T -#define H5_SIZEOF_INT64_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG >= 8 -typedef long int64_t; -#undef H5_SIZEOF_INT64_T -#define H5_SIZEOF_INT64_T H5_SIZEOF_LONG -#elif H5_SIZEOF_LONG_LONG >= 8 -typedef long long int64_t; -#undef H5_SIZEOF_INT64_T -#define H5_SIZEOF_INT64_T H5_SIZEOF_LONG_LONG -#else -#error "nothing appropriate for int64_t" -#endif - -/* uint64_t type is used for fields for H5O_info_t. It may be - * defined in Posix.1g, otherwise it is defined here. +/** + * The size of file objects. + * + * \internal Defined as a (minimum) 64-bit integer type. */ -#if H5_SIZEOF_UINT64_T >= 8 -#ifndef UINT64_MAX -#define UINT64_MAX ((uint64_t)-1) -#endif -#elif H5_SIZEOF_INT >= 8 -typedef unsigned uint64_t; -#define UINT64_MAX UINT_MAX -#undef H5_SIZEOF_UINT64_T -#define H5_SIZEOF_UINT64_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG >= 8 -typedef unsigned long uint64_t; -#define UINT64_MAX ULONG_MAX -#undef H5_SIZEOF_UINT64_T -#define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG -#elif H5_SIZEOF_LONG_LONG >= 8 -typedef unsigned long long uint64_t; -#define UINT64_MAX ULLONG_MAX -#undef H5_SIZEOF_UINT64_T -#define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG_LONG -#else -#error "nothing appropriate for uint64_t" -#endif - -/* - * The sizes of file objects have their own types defined here, use a minimum - * 64-bit type. - */ -#if H5_SIZEOF_LONG_LONG >= 8 -H5_GCC_DIAG_OFF("long-long") -typedef unsigned long long hsize_t; -typedef signed long long hssize_t; -H5_GCC_DIAG_ON("long-long") -#define PRIdHSIZE H5_PRINTF_LL_WIDTH "d" -#define PRIiHSIZE H5_PRINTF_LL_WIDTH "i" -#define PRIoHSIZE H5_PRINTF_LL_WIDTH "o" -#define PRIuHSIZE H5_PRINTF_LL_WIDTH "u" -#define PRIxHSIZE H5_PRINTF_LL_WIDTH "x" -#define PRIXHSIZE H5_PRINTF_LL_WIDTH "X" -#define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG_LONG -#define H5_SIZEOF_HSSIZE_T H5_SIZEOF_LONG_LONG -#define HSIZE_UNDEF ULLONG_MAX -#else -#error "nothing appropriate for hsize_t" -#endif +typedef uint64_t hsize_t; +/** + * The size of file objects. Used when negative values are needed to indicate errors. + * + * \internal Defined as a (minimum) 64-bit integer type. Use of hssize_t + * should be discouraged in new code. + */ +typedef int64_t hssize_t; +#define PRIdHSIZE PRId64 +#define PRIiHSIZE PRIi64 +#define PRIoHSIZE PRIo64 +#define PRIuHSIZE PRIu64 +#define PRIxHSIZE PRIx64 +#define PRIXHSIZE PRIX64 +#define H5_SIZEOF_HSIZE_T 8 +#define H5_SIZEOF_HSSIZE_T 8 +#define HSIZE_UNDEF UINT64_MAX -/* - * File addresses have their own types. - */ -#if H5_SIZEOF_INT >= 8 -typedef unsigned haddr_t; -#define HADDR_UNDEF UINT_MAX -#define H5_SIZEOF_HADDR_T H5_SIZEOF_INT -#ifdef H5_HAVE_PARALLEL -#define HADDR_AS_MPI_TYPE MPI_UNSIGNED -#endif /* H5_HAVE_PARALLEL */ -#define PRIdHADDR "d" -#define PRIoHADDR "o" -#define PRIuHADDR "u" -#define PRIxHADDR "x" -#define PRIXHADDR "X" -#elif H5_SIZEOF_LONG >= 8 -typedef unsigned long haddr_t; -#define HADDR_UNDEF ULONG_MAX -#define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG -#ifdef H5_HAVE_PARALLEL -#define HADDR_AS_MPI_TYPE MPI_UNSIGNED_LONG -#endif /* H5_HAVE_PARALLEL */ -#define PRIdHADDR "ld" -#define PRIoHADDR "lo" -#define PRIuHADDR "lu" -#define PRIxHADDR "lx" -#define PRIXHADDR "lX" -#elif H5_SIZEOF_LONG_LONG >= 8 -typedef unsigned long long haddr_t; -#define HADDR_UNDEF ULLONG_MAX -#define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG_LONG -#ifdef H5_HAVE_PARALLEL -#define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT -#endif /* H5_HAVE_PARALLEL */ -#define PRIdHADDR H5_PRINTF_LL_WIDTH "d" -#define PRIoHADDR H5_PRINTF_LL_WIDTH "o" -#define PRIuHADDR H5_PRINTF_LL_WIDTH "u" -#define PRIxHADDR H5_PRINTF_LL_WIDTH "x" -#define PRIXHADDR H5_PRINTF_LL_WIDTH "X" -#else -#error "nothing appropriate for haddr_t" -#endif +/** + * The address of an object in the file. + * + * \internal Defined as a (minimum) 64-bit unsigned integer type. + */ +typedef uint64_t haddr_t; +#define PRIdHADDR PRId64 +#define PRIoHADDR PRIo64 +#define PRIuHADDR PRIu64 +#define PRIxHADDR PRIx64 +#define PRIXHADDR PRIX64 +#define H5_SIZEOF_HADDR_T 8 +#define HADDR_UNDEF UINT64_MAX #define H5_PRINTF_HADDR_FMT "%" PRIuHADDR #define HADDR_MAX (HADDR_UNDEF - 1) -/* uint32_t type is used for creation order field for messages. It may be - * defined in Posix.1g, otherwise it is defined here. - */ -#if H5_SIZEOF_UINT32_T >= 4 -#elif H5_SIZEOF_SHORT >= 4 -typedef short uint32_t; -#undef H5_SIZEOF_UINT32_T -#define H5_SIZEOF_UINT32_T H5_SIZEOF_SHORT -#elif H5_SIZEOF_INT >= 4 -typedef unsigned int uint32_t; -#undef H5_SIZEOF_UINT32_T -#define H5_SIZEOF_UINT32_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG >= 4 -typedef unsigned long uint32_t; -#undef H5_SIZEOF_UINT32_T -#define H5_SIZEOF_UINT32_T H5_SIZEOF_LONG -#else -#error "nothing appropriate for uint32_t" +#ifdef H5_HAVE_PARALLEL +#define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT #endif //! diff --git a/tools/test/perform/overhead.c b/tools/test/perform/overhead.c index 345c5c8..60ec8d8 100644 --- a/tools/test/perform/overhead.c +++ b/tools/test/perform/overhead.c @@ -29,10 +29,6 @@ #include #include -#ifdef H5_HAVE_IO_H -#include -#endif - #ifdef H5_HAVE_UNISTD_H #include #include -- cgit v0.12