diff --git a/CMakeLists.txt b/CMakeLists.txt index 96852ed60..8c3e9eeae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -547,6 +547,11 @@ else() set(NETCDF_ENABLE_HDF4 OFF) endif() +# Option legacy macros +# Do we want to enable unsafe macros, e.g. _FillValue in addition to NC_FillValue. +# See https://github.com/Unidata/netcdf-c/issues/3029 +option(NETCDF_ENABLE_LEGACY_MACROS "Enable legacy macros for backwards compatibility. Use with Caution." ON) + # Option Logging, only valid for netcdf4 dispatchers. option(NETCDF_ENABLE_LOGGING "Enable Logging." OFF) if(NOT NETCDF_ENABLE_NETCDF4) @@ -662,14 +667,18 @@ if(ENABLE_PLUGIN_INSTALL) set(NETCDF_PLUGIN_INSTALL_DIR "$ENV{HDF5_PLUGIN_PATH}") else() if(ISMSVC OR ISMINGW) - set(NETCDF_PLUGIN_INSTALL_DIR "$ENV{ALLUSERSPROFILE}\\hdf5\\lib\\plugin") - else() - set(NETCDF_PLUGIN_INSTALL_DIR "/usr/local/hdf5/lib/plugin") - endif() - endif() - message(STATUS "Defaulting to -DPLUGIN_INSTALL_DIR=${NETCDF_PLUGIN_INSTALL_DIR}") + set(NETCDF_PLUGIN_INSTALL_DIR "$ENV{ALLUSERSPROFILE}\\hdf5\\lib\\plugin") + else() + if(NOT DEFINED CMAKE_INSTALL_PREFIX) + set(NETCDF_PLUGIN_INSTALL_DIR "/usr/local/hdf5/lib/plugin") + else() + set(NETCDF_PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/hdf5/lib/plugin") + endif(NOT DEFINED CMAKE_INSTALL_PREFIX) + endif(ISMSVC OR ISMINGW) + endif(DEFINED ENV{HDF5_PLUGIN_PATH}) + message(STATUS "Defaulting to -DPLUGIN_INSTALL_DIR=${NETCDF_PLUGIN_INSTALL_DIR}") endif() -endif() +endif(ENABLE_PLUGIN_INSTALL) if(ENABLE_PLUGIN_INSTALL) # Use the lowest priority dir in the path @@ -1694,6 +1703,7 @@ is_enabled(NETCDF_ENABLE_PARALLEL4 HAS_PARALLEL4) is_enabled(NETCDF_ENABLE_DAP HAS_DAP) is_enabled(NETCDF_ENABLE_DAP2 HAS_DAP2) is_enabled(NETCDF_ENABLE_DAP4 HAS_DAP4) +is_enabled(NETCDF_ENABLE_LEGACY_MACROS HAS_LEGACY_MACROS) is_enabled(NETCDF_ENABLE_BYTERANGE HAS_BYTERANGE) is_enabled(NETCDF_ENABLE_DISKLESS HAS_DISKLESS) is_enabled(USE_MMAP HAS_MMAP) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index cfcaa3149..dce1f1291 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -9,12 +9,14 @@ This file contains a high-level description of this package's evolution. Release ## Known Issue -* Parallel operation using `mpich 4.2.0` (the default on `Ubuntu 24.04`) results in 'unexpected results' when running `nc_test4/run_par_test.sh`. This can be fixed by removing `mpich` and associated libraries and development packages and installing `mpich 4.2.2` by hand, or by using `openmpi` provided via `apt`. +> Parallel operation using `mpich 4.2.0` (the default on `Ubuntu 24.04`) results in 'unexpected results' when running `nc_test4/run_par_test.sh`. This can be fixed by removing `mpich` and associated libraries and development packages and installing `mpich 4.2.2` by hand, or by using `openmpi` provided via `apt`. ## Release Notes ### Release Candidate 2 - TBD +> Note: To avoid a conflict between `_FillValue` and `libc++18`, we have introduced a new option, `--enable-legacy-macros` for autotools and `NETCDF_ENABLE_LEGACY_MACROS` for cmake. These are turned on by default currently but will be turned off eventually. Developers are encouraged to move away from the `FillValue` macro and replace it with the new `NC_FillValue` macro. See [Github #2858](https://github.com/Unidata/netcdf-c/issues/2858) for more information. + * Provide better documentation for the .rc file mechanism and API. See [Github #2956](https://github.com/Unidata/netcdf-c/pull/2956) for more information. * Convert NCZarr V2 to store all netcdf-4 specific info as attributes. This improves interoperability with other Zarr implementations by no longer using non-standard keys. The price to be paid is that lazy attribute reading cannot be supported. See [Github #2836](https://github.com/Unidata/netcdf-c/pull/2936) for more information. * Cleanup the option code for NETCDF_ENABLE_SET_LOG_LEVEL\[_FUNC\] See [Github #2931](https://github.com/Unidata/netcdf-c/pull/2931) for more information. diff --git a/config.h.cmake.in b/config.h.cmake.in index 3e0bff607..b1b0507a2 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -496,6 +496,9 @@ with zip */ /* Idspatch table version */ #cmakedefine NC_DISPATCH_VERSION ${NC_DISPATCH_VERSION} +/* Enable Legacy, potential-conflict Macro _FillValue */ +#cmakedefine NETCDF_ENABLE_LEGACY_MACROS + /* no IEEE float on this platform */ #cmakedefine NO_IEEE_FLOAT 1 diff --git a/configure.ac b/configure.ac index 33c85470e..fb6642281 100644 --- a/configure.ac +++ b/configure.ac @@ -462,6 +462,19 @@ else enable_set_log_level=no fi +# Do we want to enable unsafe macros, e.g. _FillValue in addition to NC_FillValue. +# See https://github.com/Unidata/netcdf-c/issues/3029 +AC_MSG_CHECKING([whether to allow legacy macros]) +AC_ARG_ENABLE([legacy-macros], + [AS_HELP_STRING([--disable-legacy-macros], + [enable legacy macros for backwards compatibility purposes. Use with caution.\ + This can lead to unexpected consequences/behavior.])]) +test "x$enable_legacy_macros" = xno || enable_legacy_macros=yes +AC_MSG_RESULT($enable_legacy_macros) +if test "x$enable_legacy_macros" = xyes; then + AC_DEFINE([NETCDF_ENABLE_LEGACY_MACROS], 1, [If true, enable legacy macros in netcdf.h]) +fi + # Does the user want to allow reading of remote data via range headers? AC_MSG_CHECKING([whether byte range support is enabled]) AC_ARG_ENABLE([byterange], @@ -1932,6 +1945,7 @@ AM_CONDITIONAL(USE_DAP, [test "x$enable_dap" = xyes]) # Alias # Provide protocol specific flags AM_CONDITIONAL(NETCDF_ENABLE_DAP, [test "x$enable_dap" = xyes]) AM_CONDITIONAL(NETCDF_ENABLE_DAP4, [test "x$enable_dap4" = xyes]) +AM_CONDITIONAL(NETCDF_ENABLE_LEGACY_MACROS, [test "x$netcdf_enable_legacy_macros" = xyes]) AM_CONDITIONAL(USE_STRICT_NULL_BYTE_HEADER_PADDING, [test x$enable_strict_null_byte_header_padding = xyes]) AM_CONDITIONAL(NETCDF_ENABLE_CDF5, [test "x$enable_cdf5" = xyes]) AM_CONDITIONAL(NETCDF_ENABLE_DAP_REMOTE_TESTS, [test "x$enable_dap_remote_tests" = xyes]) @@ -2050,6 +2064,7 @@ AC_SUBST(NC_LIBS,[$NC_LIBS]) AC_SUBST(HAS_DAP,[$enable_dap]) AC_SUBST(HAS_DAP2,[$enable_dap]) AC_SUBST(HAS_DAP4,[$enable_dap4]) +AC_SUBST(HAS_LEGACY_MACROS,[$enable_legacy_macros]) AC_SUBST(HAS_NC2,[$nc_build_v2]) AC_SUBST(HAS_CDF5,[$enable_cdf5]) AC_SUBST(HAS_HDF4,[$enable_hdf4]) @@ -2156,8 +2171,13 @@ elif test "x$with_plugin_dir" = xyes ; then # --with-plugin-dir, no argument if test "x$ISMSVC" = xyes || test "x$ISMINGW" = xyes; then PLUGIN_PATH="${ALLUSERSPROFILE}\\hdfd5\\lib\\plugin" else - PLUGIN_PATH="/usr/local/hdf5/lib/plugin" - fi + if test "x${prefix}" = xNONE ; then + PLUGIN_PATH="/usr/local/hdf5/lib/plugin" + else + PLUGIN_PATH="${prefix}/hdf5/lib/plugin" + fi + + fi fi # Use the lowest priority dir in the path if test "x$ISMSVC" = xyes || test "x$ISMINGW" = xyes; then diff --git a/include/netcdf.h b/include/netcdf.h index ceaeed2b0..1718ccdfa 100644 --- a/include/netcdf.h +++ b/include/netcdf.h @@ -109,7 +109,15 @@ extern "C" { * different value than the above defaults, create an attribute with * the same type as the variable and this reserved name. The value you * give the attribute will be used as the fill value for that - * variable. */ + * variable. + * Refactored to NC_FillValue in support of + * https://github.com/Unidata/netcdf-c/issues/2858, and parameterized + * behind an unsafe macros option as part of + * https://github.com/Unidata/netcdf-c/issues/3029 + */ +#ifdef NETCDF_ENABLE_LEGACY_MACROS +#define _FillValue "_FillValue" +#endif #define NC_FillValue "_FillValue" #define NC_FILL 0 /**< Argument to nc_set_fill() to clear NC_NOFILL */ #define NC_NOFILL 0x100 /**< Argument to nc_set_fill() to turn off filling of data. */ diff --git a/libnetcdf.settings.in b/libnetcdf.settings.in index 4cf899a47..4aac31c1c 100644 --- a/libnetcdf.settings.in +++ b/libnetcdf.settings.in @@ -24,6 +24,7 @@ Shared Library: @enable_shared@ Static Library: @enable_static@ Extra libraries: @LIBS@ XML Parser: @XMLPARSER@ +Legacy Macros: @HAS_LEGACY_MACROS@ # Features -------- diff --git a/plugins/Makefile.am b/plugins/Makefile.am index b9fc2d177..b92e3095b 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -14,7 +14,7 @@ AM_LDFLAGS += -module -avoid-version -shared -export-dynamic $(NOUNDEFINED) # Create an alternate directory if not installing. ALTPLUGINDIR = ${abs_top_builddir}/plugins/plugindir -RPATH = -rpath $(abs_builddir)/.libs +RPATH = -rpath $(abs_top_builddir)/.libs # This is where the plugins are to be installed if ENABLE_PLUGIN_DIR