Skip to content

Commit

Permalink
Eliminate easy warnings, fix some code issues. (#22)
Browse files Browse the repository at this point in the history
* Eliminate easy warnings, fix some code issues.

* Check for positive edges in fill buffer

* Add CHECK status to examples

* Rename and move macro to hdf.h header

* Fix comment, Correct flag variable for CXX
  • Loading branch information
byrnHDF authored Jun 17, 2022
1 parent 618a935 commit 31f75f7
Show file tree
Hide file tree
Showing 153 changed files with 9,322 additions and 9,036 deletions.
17 changes: 7 additions & 10 deletions CMakeInstallation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ if (NOT HDF4_EXTERNALLY_CONFIGURED)
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
COMPONENT configinstall
)
endif ()

#-----------------------------------------------------------------------------
# Export all exported targets to the build tree for use by parent project
#-----------------------------------------------------------------------------
if (NOT HDF4_EXTERNALLY_CONFIGURED)
#-----------------------------------------------------------------------------
# Export all exported targets to the build tree for use by parent project
#-----------------------------------------------------------------------------
export (
TARGETS ${HDF4_LIBRARIES_TO_EXPORT} ${HDF4_LIB_DEPENDENCIES} ${HDF4_UTILS_TO_EXPORT}
FILE ${HDF4_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
Expand Down Expand Up @@ -184,7 +182,7 @@ HDF_README_PROPERTIES(HDF4_BUILD_FORTRAN)
#-----------------------------------------------------------------------------
# Configure the COPYING.txt file for the windows binary package
#-----------------------------------------------------------------------------
if (WIN32 OR MINGW)
if (WIN32)
configure_file (${HDF4_SOURCE_DIR}/COPYING ${HDF4_BINARY_DIR}/COPYING.txt @ONLY)
endif ()

Expand All @@ -193,8 +191,7 @@ endif ()
#-----------------------------------------------------------------------------
if (NOT HDF4_EXTERNALLY_CONFIGURED)
install (
FILES
${HDF4_SOURCE_DIR}/COPYING
FILES ${HDF4_SOURCE_DIR}/COPYING
DESTINATION ${HDF4_INSTALL_DATA_DIR}
COMPONENT hdfdocuments
)
Expand All @@ -203,7 +200,7 @@ if (NOT HDF4_EXTERNALLY_CONFIGURED)
${HDF4_SOURCE_DIR}/release_notes/USING_HDF4_CMake.txt
${HDF4_SOURCE_DIR}/release_notes/RELEASE.txt
)
if (WIN32 OR MINGW)
if (WIN32)
set (release_files
${release_files}
${HDF4_SOURCE_DIR}/release_notes/USING_HDF4_VS.txt
Expand All @@ -216,7 +213,7 @@ if (NOT HDF4_EXTERNALLY_CONFIGURED)
${HDF4_SOURCE_DIR}/release_notes/HISTORY.txt
${HDF4_SOURCE_DIR}/release_notes/INSTALL
)
if (WIN32 OR MINGW)
if (WIN32)
set (release_files
${release_files}
${HDF4_SOURCE_DIR}/release_notes/INSTALL_Windows.txt
Expand Down
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ if (POLICY CMP0074)
cmake_policy (SET CMP0074 NEW)
endif ()

if (POLICY CMP0083)
cmake_policy (SET CMP0083 NEW)
endif ()

#-----------------------------------------------------------------------------
# Instructions for use : Normal Build
#
Expand Down Expand Up @@ -37,8 +41,8 @@ endif ()
set (CMAKE_IGNORE_EOL "--ignore-eol")
if (CMAKE_VERSION VERSION_LESS "3.14.0")
set (CMAKE_IGNORE_EOL "")
# if (WIN32)
# message (FATAL_ERROR "Windows builds require a minimum of CMake 3.14")
#if(CMAKE_VERSION VERSION_LESS "3.14.0" AND WIN32)
# MESSAGE(FATAL_ERROR "Windows builds requires a minimum of CMake 3.14")
# endif()
endif ()

Expand Down Expand Up @@ -397,13 +401,17 @@ INCLUDE_DIRECTORIES (${HDF4_INCLUDE_DIRECTORIES} )
# Certain systems may add /Debug or /Release to output paths
# and we need to call the executable from inside the CMake configuration
#-----------------------------------------------------------------------------
set (EXE_EXT "")
if (WIN32)
set (EXE_EXT ".exe")
add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
if (MSVC)
add_compile_definitions (_BIND_TO_CURRENT_VCLIBS_VERSION=1 _CONSOLE)
endif ()
endif ()

option (HDF5_MINGW_STATIC_GCC_LIBS "Statically link libgcc/libstdc++" OFF)

if (MSVC)
set (CMAKE_MFC_FLAG 0)
set (WIN_COMPILE_FLAGS "")
Expand Down
6 changes: 3 additions & 3 deletions config/cmake/HDFCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ else ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=implicit-function-declaration")
endif ()
if (CMAKE_CXX_COMPILER_LOADED)
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
if (_INTEL_WINDOWS)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wcheck /Wall")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wcheck /Wall")
else ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcheck -Wall")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcheck -Wall")
endif ()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra")
Expand Down
2 changes: 1 addition & 1 deletion config/cmake/README.txt.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The contents of this directory are:

This binary was built with the ZLIB and SZIP/Libaec external libraries and are
included for convenience. Libaec is an unrestricted open-source replacement for SZIP
(Encoder ENABLED).
(version 1.0.4, Encoder ENABLED).

The official ZLIB and SZIP/Libaec pages are at:

Expand Down
4 changes: 3 additions & 1 deletion config/cmake/cacheinit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set (CMAKE_INSTALL_FRAMEWORK_PREFIX "Library/Frameworks" CACHE STRING "Framework

set (HDF_PACKAGE_EXT "" CACHE STRING "Name of HDF package extension" FORCE)

set (HDF_PACKAGE_NAMESPACE "hdf4::" CACHE STRING "Name for HDF package namespace" FORCE)
set (HDF_PACKAGE_NAMESPACE "hdf4::" CACHE STRING "Name for HDF package namespace (can be empty)" FORCE)

set (HDF4_BUILD_FORTRAN ON CACHE BOOL "Build FORTRAN support" FORCE)

Expand Down Expand Up @@ -48,6 +48,8 @@ set (HDF4_PACKAGE_EXTLIBS OFF CACHE BOOL "(WINDOWS)CPACK - include external libr

set (HDF4_NO_PACKAGES OFF CACHE BOOL "CPACK - Disable packaging" FORCE)

set (HDF4_MINGW_STATIC_GCC_LIBS ON CACHE BOOL "Statically link libgcc/libstdc++" FORCE)

set (HDF4_ALLOW_EXTERNAL_SUPPORT "NO" CACHE STRING "Allow External Library Building (NO GIT SVN TGZ)" FORCE)
set_property (CACHE HDF4_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO GIT SVN TGZ)

Expand Down
3 changes: 1 addition & 2 deletions config/cmake/mccacheinit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ set (USE_LIBAEC ON CACHE BOOL "Use libaec szip replacement" FORCE)

set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Debug" FORCE)

set (JPEG_TGZ_NAME "JPEG8d.tar.gz" CACHE STRING "Use JPEG from compressed file" FORCE)
set (JPEG_TGZ_NAME "JPEG9d.tar.gz" CACHE STRING "Use JPEG from compressed file" FORCE)

set (ZLIB_PACKAGE_NAME "zlib" CACHE STRING "Name of ZLIB package" FORCE)
set (LIBAEC_PACKAGE_NAME "libaec" CACHE STRING "Name of AEC SZIP package" FORCE)
set (SZIP_PACKAGE_NAME "szip" CACHE STRING "Name of SZIP package" FORCE)

set (JPEG_PACKAGE_NAME "jpeg" CACHE STRING "Name of JPEG package" FORCE)
41 changes: 30 additions & 11 deletions hdf/examples/AN_create_annotation.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,90 +28,109 @@ int main( )
* Create the HDF file.
*/
file_id = Hopen (FILE_NAME, DFACC_CREATE, 0);
CHECK_NOT_VAL(file_id, FAIL, "Hopen");

/*
* Initialize the AN interface.
*/
an_id = ANstart (file_id);
CHECK_NOT_VAL(an_id, FAIL, "ANstart");

/*
* Create the file label.
*/
file_label_id = ANcreatef (an_id, AN_FILE_LABEL);
CHECK_NOT_VAL(file_label_id, FAIL, "AN_FILE_LABEL");

/*
* Write the annotations to the file label.
*/
status_32 = ANwriteann (file_label_id, FILE_LABEL_TXT,
strlen (FILE_LABEL_TXT));
status_32 = ANwriteann (file_label_id, FILE_LABEL_TXT, strlen (FILE_LABEL_TXT));
CHECK_NOT_VAL(status_32, FAIL, "ANwriteann");

/*
* Create file description.
*/
file_desc_id = ANcreatef (an_id, AN_FILE_DESC);
CHECK_NOT_VAL(file_desc_id, FAIL, "ANcreatef");

/*
* Write the annotation to the file description.
* Write the annotation to the file description.
*/
status_32 = ANwriteann (file_desc_id, FILE_DESC_TXT,
strlen (FILE_DESC_TXT));
status_32 = ANwriteann (file_desc_id, FILE_DESC_TXT, strlen (FILE_DESC_TXT));
CHECK_NOT_VAL(status_32, FAIL, "ANwriteann");

/*
* Create a vgroup in the V interface. Note that the vgroup's ref number
* Create a vgroup in the V interface. Note that the vgroup's ref number
* is set to -1 for creating and the access mode is "w" for writing.
*/
status_n = Vstart (file_id);
CHECK_NOT_VAL(status_n, FAIL, "Vstart");
vgroup_id = Vattach (file_id, -1, "w");
CHECK_NOT_VAL(vgroup_id, FAIL, "Vattach");
status_32 = Vsetname (vgroup_id, VG_NAME);
CHECK_NOT_VAL(status_32, FAIL, "Vsetname");

/*
* Obtain the tag and ref number of the vgroup for subsequent
* references.
* references.
*/
vgroup_tag = (uint16) VQuerytag (vgroup_id);
vgroup_ref = (uint16) VQueryref (vgroup_id);

/*
* Create the data label for the vgroup identified by its tag
* Create the data label for the vgroup identified by its tag
* and ref number.
*/
data_label_id = ANcreate (an_id, vgroup_tag, vgroup_ref, AN_DATA_LABEL);
CHECK_NOT_VAL(data_label_id, FAIL, "ANcreate");

/*
* Write the annotation text to the data label.
*/
status_32 = ANwriteann (data_label_id, DATA_LABEL_TXT,
strlen (DATA_LABEL_TXT));
status_32 = ANwriteann (data_label_id, DATA_LABEL_TXT, strlen (DATA_LABEL_TXT));
CHECK_NOT_VAL(status_32, FAIL, "ANwriteann");

/*
* Create the data description for the vgroup identified by its tag
* Create the data description for the vgroup identified by its tag
* and ref number.
*/
data_desc_id = ANcreate (an_id, vgroup_tag, vgroup_ref, AN_DATA_DESC);
CHECK_NOT_VAL(data_desc_id, FAIL, "ANcreate");

/*
* Write the annotation text to the data description.
*/
status_32 = ANwriteann (data_desc_id, DATA_DESC_TXT, strlen (DATA_DESC_TXT));
CHECK_NOT_VAL(status_32, FAIL, "ANwriteann");

/*
* Teminate access to the vgroup and to the V interface.
*/
status_32 = Vdetach (vgroup_id);
CHECK_NOT_VAL(status_32, FAIL, "Vdetach");
status_n = Vend (file_id);
CHECK_NOT_VAL(status_n, FAIL, "Vend");

/*
* Terminate access to each annotation explicitly.
*/
status_n = ANendaccess (file_label_id);
CHECK_NOT_VAL(status_n, FAIL, "ANendaccess");
status_n = ANendaccess (file_desc_id);
CHECK_NOT_VAL(status_n, FAIL, "ANendaccess");
status_n = ANendaccess (data_label_id);
CHECK_NOT_VAL(status_n, FAIL, "ANendaccess");
status_n = ANendaccess (data_desc_id);
CHECK_NOT_VAL(status_n, FAIL, "ANendaccess");

/*
* Terminate access to the AN interface and close the HDF file.
*/
status_32 = ANend (an_id);
CHECK_NOT_VAL(status_32, FAIL, "ANend");
status_n = Hclose (file_id);
CHECK_NOT_VAL(status_n, FAIL, "Hclose");

return 0;
}
25 changes: 16 additions & 9 deletions hdf/examples/AN_get_annotation_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ int main( )

intn status_n; /* returned status for functions returning an intn */
int32 status_32, /* returned status for functions returning an int32*/
file_id, an_id, ann_id,
file_id, an_id,
n_annots, /* number of annotations */
*ann_list, /* list of annotation identifiers */
*ann_list = NULL, /* list of annotation identifiers */
vgroup_ref, /* reference number of the vgroup */
index; /* index of an annotation in the annotation list */
ann_type annot_type = AN_DATA_DESC; /* annotation to be obtained*/
Expand All @@ -29,16 +29,19 @@ int main( )
* Initialize the V interface.
*/
status_n = Vstart (file_id);
CHECK_NOT_VAL(status_n, FAIL, "Vstart");

/*
* Get the vgroup named VG_NAME.
*/
vgroup_ref = Vfind (file_id, VG_NAME);
CHECK_NOT_VAL(vgroup_ref, FAIL, "Vfind");

/*
* Initialize the AN interface and obtain an interface id.
*/
an_id = ANstart (file_id);
CHECK_NOT_VAL(an_id, FAIL, "ANstart");

/*
* Get the number of object descriptions. Note that, since ANnumann takes
Expand All @@ -55,25 +58,26 @@ int main( )
ann_list = malloc (n_annots * sizeof (int32));

/*
* Get the list of identifiers of the annotations attached to the
* Get the list of identifiers of the annotations attached to the
* vgroup and of type annot_type.
*/
n_annots = ANannlist (an_id, annot_type, vgroup_tag, (uint16)vgroup_ref,
n_annots = ANannlist (an_id, annot_type, vgroup_tag, (uint16)vgroup_ref,
ann_list);

/*
* Get each annotation identifier from the list then display the
* Get each annotation identifier from the list then display the
* tag/ref number pair of the corresponding annotation.
*/
printf ("List of annotations of type AN_DATA_DESC:\n");
for (index = 0; index < n_annots; index++)
{
/*
* Get and display the ref number of the annotation from
* Get and display the ref number of the annotation from
* its identifier.
*/
status_32 = ANid2tagref (ann_list[index], &ann_tag, &ann_ref);
printf ("Annotation index %d: tag = %s\nreference number= %d\n",
CHECK_NOT_VAL(status_32, FAIL, "ANid2tagref");
printf ("Annotation index %d: tag = %s\nreference number= %d\n",
index, ann_tag == DFTAG_DIA ? "DFTAG_DIA (data description)":
"Incorrect", ann_ref);
} /* for */
Expand All @@ -83,25 +87,28 @@ int main( )
* Get and display an annotation type from an annotation tag.
*/
annot_type = ANtag2atype (DFTAG_FID);
printf ("\nAnnotation type of DFTAG_FID (file label) is %s\n",
printf ("\nAnnotation type of DFTAG_FID (file label) is %s\n",
annot_type == AN_FILE_LABEL ? "AN_FILE_LABEL":"Incorrect");

/*
* Get and display an annotation tag from an annotation type.
*/
ann_tag = ANatype2tag (AN_DATA_LABEL);
printf ("\nAnnotation tag of AN_DATA_LABEL is %s\n",
printf ("\nAnnotation tag of AN_DATA_LABEL is %s\n",
ann_tag == DFTAG_DIL ? "DFTAG_DIL (data label)":"Incorrect");

/*
* Terminate access to the AN interface and close the HDF file.
*/
status_32 = ANend (an_id);
CHECK_NOT_VAL(status_32, FAIL, "ANend");
status_n = Hclose (file_id);
CHECK_NOT_VAL(status_n, FAIL, "Hclose");

/*
* Free the space allocated for the annotation identifier list.
*/
free (ann_list);

return 0;
}
Loading

0 comments on commit 31f75f7

Please sign in to comment.