@@ -72,8 +72,13 @@ bool H5_PKG_INIT_VAR = false;
7272/* Library Private Variables */
7373/*****************************/
7474
75- /* Library incompatible minor versions, develop releases are incompatible by design */
76- static const unsigned VERS_MINOR_EXCEPTIONS [] = {0 };
75+ /* Library known incompatible minor versions; develop releases are incompatible
76+ * by design. 999 is entered for testing an exception as a minor version that
77+ * will never occur. Any released minor version found to be truly incompatible
78+ * (this should never happen) should be added to the list with 999. 999 alone
79+ * in the list indicates that there are no incompatible minor versions. */
80+ static const unsigned VERS_MINOR_EXCEPTIONS [] = {999 };
81+ /* The size should be set to the number of minor version exceptions in the list. */
7782static const unsigned VERS_MINOR_EXCEPTIONS_SIZE = 1 ;
7883
7984/* Library init / term status (global) */
@@ -832,6 +837,15 @@ H5get_libversion(unsigned *majnum /*out*/, unsigned *minnum /*out*/, unsigned *r
832837 "linked with an incompatible version of static or shared HDF5 library.\n" \
833838 "You should recompile the application or check your shared library related\n" \
834839 "settings such as 'LD_LIBRARY_PATH'.\n"
840+ #define MINOR_VERSION_FORWARD_COMPATIBLE_WARNING \
841+ "Warning! ***HDF5 library minor version forward compatibility error***\n" \
842+ "The HDF5 header files used to compile this application are from a newer\n" \
843+ "version of the HDF5 library than the one to which this application is linked.\n" \
844+ "Data corruption or segmentation faults may occur if the application continues.\n" \
845+ "This can happen when an application was compiled by a newer version of HDF5 but\n" \
846+ "linked with an older version of static or shared HDF5 library.\n" \
847+ "You should recompile the application or check your shared library related\n" \
848+ "settings such as 'LD_LIBRARY_PATH'.\n"
835849
836850static herr_t
837851H5_check_version (unsigned majnum , unsigned minnum , unsigned relnum )
@@ -842,6 +856,7 @@ H5_check_version(unsigned majnum, unsigned minnum, unsigned relnum)
842856 static unsigned int disable_version_check = 0 ; /* Set if the version check should be disabled */
843857 static const char * version_mismatch_warning = VERSION_MISMATCH_WARNING ;
844858 static const char * minor_version_mismatch_warning = MINOR_VERSION_MISMATCH_WARNING ;
859+ static const char * minor_version_forward_compatible_warning = MINOR_VERSION_FORWARD_COMPATIBLE_WARNING ;
845860 herr_t ret_value = SUCCEED ; /* Return value */
846861
847862 FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -938,6 +953,40 @@ H5_check_version(unsigned majnum, unsigned minnum, unsigned relnum)
938953
939954 } /* end for */
940955
956+ /* Check for forward compatibilty usage. */
957+ if (H5_VERS_MINOR > minnum ) {
958+ switch (disable_version_check ) {
959+ case 0 :
960+ fprintf (stderr , "%s%s" , minor_version_forward_compatible_warning ,
961+ "You can, at your own risk, disable this warning by setting the environment\n"
962+ "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.\n"
963+ "Setting it to 2 or higher will suppress the warning messages totally.\n" );
964+ /* Mention the versions we are referring to */
965+ fprintf (stderr , "Headers are %u.%u.%u, library is %u.%u.%u\n" , majnum , minnum , relnum ,
966+ (unsigned )H5_VERS_MAJOR , (unsigned )H5_VERS_MINOR , (unsigned )H5_VERS_RELEASE );
967+
968+ /* Bail out now. */
969+ fputs ("Bye...\n" , stderr );
970+ abort ();
971+ case 1 :
972+ /* continue with a warning */
973+ /* Note that the warning message is embedded in the format string.*/
974+ fprintf (stderr ,
975+ "%s'HDF5_DISABLE_VERSION_CHECK' "
976+ "environment variable is set to %d, application will\n"
977+ "continue at your own risk.\n" ,
978+ minor_version_forward_compatible_warning , disable_version_check );
979+ /* Mention the versions we are referring to */
980+ fprintf (stderr , "Headers are %u.%u.%u, library is %u.%u.%u\n" , majnum , minnum , relnum ,
981+ (unsigned )H5_VERS_MAJOR , (unsigned )H5_VERS_MINOR , (unsigned )H5_VERS_RELEASE );
982+ break ;
983+ default :
984+ /* 2 or higher: continue silently */
985+ break ;
986+ } /* end switch */
987+
988+ }
989+
941990 } /* end if (H5_VERS_MINOR != minnum) */
942991
943992 /* Indicate that the version check has been performed */
0 commit comments